group by with rollup

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 |
+-----------------------------+-------------+

 

posted @ 2020-01-28 14:06  后山前堂客  阅读(157)  评论(0)    收藏  举报