Hello想知道如何使用PostgreSQL来和()“调用ID计数”,然后将结果放在列表的底部。我尝试过工会和团体。
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我希望得到代理的名字和那里的计数,然后总数在最后谢谢
发布于 2015-01-30 20:28:56
您必须使用UNION合并这两个查询,然后相应地使用ORDER,查看下面的示例:
Select Agent,Sum("CALL ID count") as TOTAL
from AgentCount
group by Agent
UNION
Select 'TOTAL' AS Agent ,Sum("CALL ID count") as TOTAL FROM AgentCount
ORDER BY CASE WHEN Agent = 'TOTAL' THEN 1 ELSE 0 END ASC, Agenthttps://stackoverflow.com/questions/28243945
复制相似问题