所以我想从我的数据库(postgressql)显示值(明显) 这是我的代码:
SELECT distinct t.*, round(SUM(percentage)OVER (order by agentname rows between unbounded preceding and current row),3) AS cumulative
FROM (
SELECT
a.*,
COUNT(*) AS frequency,
round(COUNT(*) * 100.00 / SUM(COUNT(*)) OVER (),4) AS percentage
FROM
(select agentname,inputdate, unnest(array[ WSalamPembuka,WKonfirmasiNamaCust, WVerifikasiData,WKemampuanBertanya,WProductKnowledge,WSolusi,WAlternativeSolusi,WSistemPelaporan,WEmpati,WResponsif,WRamahSopan,WPercayaDiri,WHoldCall,WOfferHelp,WPenutup]) as weakness
from call )as a
WHERE a.agentname like '%wendra%' and a.weakness is not null and a.weakness !='' and a.inputdate between '01/12/2015' and '08/01/2016'
group by a.agentname,a.weakness,a.inputdate
order by frequency desc
) AS t
ORDER BY frequency DESC
你可以看到我在这里得到了重复的数据。我希望它像:
解决这个问题的任何技巧?先谢谢
答案 0 :(得分:3)
您获得重复的原因是因为您按输入日期进行分组:
group by a.agentname,a.weakness,a.inputdate
只需从inputdate
子句(以及外部group by
子句)中删除select
,您就可以获得所需的结果(通过注释{注意我的更改} {1}}):
inputdate