TOTAL 30 解决方案 尝试使用union SELECT 名称,计数 FROM cte UNION SELECT ' 总计' as 名称,总计 as 计数 FROM cte2; query below gives me output of Designation , COunt , total , here total is sum of count , but total value 30 should be a at the end last row , please suggest, I am using the cte expr , with cte as ( select cm.cm_value as 'Designation', count(im.ticket_no) as 'Count' from im_ticketmaster im inner join user_master um on im.caller = um.userid inner join common_master cm on um.Designation=cm.cm_id group by cm.cm_value ) , cte2 as ( select sum(count) Total from cte ) select * from cte,cte2 Actual Output below Designation Count Total ...................................... Account Executive 4 30 Account Manager 2 30 Accountant 2 30 Accounting 16 30 AP/PR Services 5 30 Assistant Director 1 30 Required output Designation Count ...................................... Account Executive 4 Account Manager 2 Accountant 2 Accounting 16 AP/PR Services 5 Assistant Director 1 TOTAL 30 解决方案 try with union SELECT Designation, CountFROM cteUNIONSELECT 'Total' as Designation, Total as CountFROM cte2; 这篇关于请建议我如何获得列“总计”行中的值,currenlty具有以下查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-22 00:21