【发布时间】:2015-01-30 20:19:13
【问题描述】:
您好想知道如何使用 PostgreSQL 来 sum() "CALL ID count",然后将结果放在列表的底部。我尝试过 union 和 group by。
AGENT CALL ID count
xxxxx 13
xxxxx 21
xxxxx 49
xxxxx 58
xxxxx 67
xxxxx 32
xxxxx 9
xxxxx 8
xxxxx 39
xxxxx 1047
说
AGENT CALL ID count
xxxxx 13
xxxxx 21
xxxxx 49
xxxxx 58
xxxxx 67
xxxxx 32
xxxxx 9
xxxxx 8
xxxxx 39
xxxxx 1047
TOTAL 1343
Select Agent,Sum("CALL ID count") as TOTAL
from AgentCount
group by "CALL ID count"
order by Agent
我希望得到代理名称的计数,然后是最后的总数 谢谢
【问题讨论】:
-
删除 group by ,你很高兴
-
是的,这行得通,但我只给了我希望得到代理名称的总和,然后是最后的总数
-
改为按代理分组并执行 union ,因此您将有两个联合。
-
Postgres 没有 ROLLUP,太棒了。
标签: sql postgresql