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