Welcome to Knowage Q&A, where you can ask questions and receive answers from other members of the community.
0 votes
1 view

Hello, i encounter an error while saving a query dataset. the SQL code is correct and it execute on postgresql, also if i put only one subquery the dataset save and work correctly proving that there is no issue with the sql itself.

error: sbi.ds.test.error.duplication

query

select c.entityid,  c.machineid,  c.area,  c.location,  sequencenumber,  removaldate,  coinsamount,  notesamount,  tinremoved,  tininstalled,  recyclerbefore,

  recyclerafter,active,serialnumber,  description,  model,  d.area,  precinct,  d.location,  tariffid,  controlledspaces,  latitude,  longitude,  locationcomment,

  tariffversion,  status,  coinsvaultlimit,  notesvaultlimit,  firmwareversion,  allversions,  ipaddress,  scr,  sim,  custom1,  custom2,  custom3,  custom4,

  notes,  pbpzoneid,  pbplocationid,  sendflags,  customername,  gstnumber,  vaultkeycode,  recyclersize,  lastmessagetime, lasttransactiontime,  runnumber,

  coinsvaulttotal,  notesvaulttotal,  notescount,  statustime,  statuserrormsg,  statuswarningmsg

from (SELECT entityid,  machineid,  area,  location,  sequencenumber,  removaldate,  coinsamount,  notesamount,  tinremoved,  tininstalled,  recyclerbefore,  recyclerafter

from  (   SELECT  entityid,  machineid,  area,  location,  sequencenumber,  removaldate,  coinsamount,  notesamount,  tinremoved,  tininstalled,  recyclerbefore,  recyclerafter,

                    ROW_NUMBER() OVER(PARTITION BY machineid ORDER BY removaldate DESC) AS RowNum

            FROM    parking.x002fparkingx002fcashremoval

        ) AS T

WHERE   RowNum = 1

) as c

inner join (select entityid, active,  machineid,  serialnumber,  description,  model,  area,  precinct,  location,  tariffid,  controlledspaces,  latitude,  longitude,  locationcomment,  tariffversion,  status,  coinsvaultlimit,  notesvaultlimit,  firmwareversion,  allversions,  ipaddress,  scr,  sim,  custom1,  custom2,  custom3,  custom4,  notes,  pbpzoneid,  pbplocationid,  sendflags,  customername,  gstnumber,  vaultkeycode,  recyclersize,  lastmessagetime, lasttransactiontime,  runnumber,  coinsvaulttotal,  notesvaulttotal,  notescount,  statustime,  statuserrormsg,  statuswarningmsg 

from  (   SELECT  *,

                    ROW_NUMBER() OVER(PARTITION BY machineid ORDER BY lasttransactiontime DESC) AS RowNum

            FROM    parking.x002fparkingx002fdevice

        ) AS T

WHERE   RowNum = 1) as d

on c.machineid = d.machineid;

Environment Knowage CE 6.1.1
in Data Set by (280 points)
After

SELECT  *,

u put here comma.

1 Answer

0 votes

Knowage cannot save dataset cause preview revealed that two columns with same name exist.

I can see at least two field:

  • area
  • location

 Please use aliases for these two and, in general, where there is an ambiguous situation. Knowage needs to refer to a specific field by using its name, but in this case it needs the alias to identify the column.

by (15.2k points)
...