group by with rollup

时间:2020-01-28 14:30:08   收藏:0   阅读:75

group by with rollup,在group by 之上在进行一次汇总

mysql> select coalesce(staff_id,汇总), sum(amount) from payment group by staff_id with rollup;
+-----------------------------+-------------+
| coalesce(staff_id,汇总)   | sum(amount) |
+-----------------------------+-------------+
| 1                           |    33489.47 |
| 2                           |    33927.04 |
| 汇总                        |    67416.51 |
+-----------------------------+-------------+

 

原文:https://www.cnblogs.com/wooluwalker/p/12237978.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!