SQL语句如何在最后增加一行合计

如题所述

用UNION就行了。
select a,b,c,d from table1 union all select sum(a) as a,sum(b) as b,sum(c) as c,sum(d) as d from table1
温馨提示:内容为网友见解,仅供参考
第1个回答  2016-11-16
GROUP BY xx WITH ROLLUP
ORDER BY xx DESC --确保“合计”行在最后一行。
相似回答