Oracle APEX DISTINCT标签?

时间:2014-09-15 12:16:58

标签: sql oracle oracle-apex

这里出了什么问题?

select NULL as "LINK",
       DISTINCT HARDWAREOVERZICHT_STATIC."TOPDESK_vestiging" as "LABEL",
count( ZAM_BUILDING) as "STORK7" 
from HARDWAREOVERZICHT_STATIC 
where Omgeving = 'STORK7'
and "TOPDESK_heeftattentie" = 0
group by HARDWAREOVERZICHT_STATIC."TOPDESK_vestiging",ZAM_BUILDING 
order by HARDWAREOVERZICHT_STATIC."TOPDESK_vestiging" desc

1 个答案:

答案 0 :(得分:0)

DISTINCT是一个跟在SELECT之后的关键字,适用于该子句中的所有列。但是,group by

通常不需要它
select NULL as "LINK", s."TOPDESK_vestiging" as "LABEL",  
      count( ZAM_BUILDING) as "STORK7"
from HARDWAREOVERZICHT_STATIC s
where Omgeving = 'STORK7' and "TOPDESK_heeftattentie" = 0
group by s."TOPDESK_vestiging"
order by s."TOPDESK_vestiging" desc;

我从ZAM_BUILDING删除了group by。否则,count()始终为01。我还添加了一个表别名。