MySQL only get overall ROLLUP

后端 未结 3 530
轻奢々
轻奢々 2021-01-20 02:23

Performing a WITH ROLLUP when grouping by multiple fields, MySQL returns a rollup row for each group, as well as the overall summary:

CREATE TAB         


        
3条回答
  •  -上瘾入骨i
    2021-01-20 03:11

    SELECT COALESCE(name, 'TOTAL') as Name, number, COUNT(1) FROM test GROUP BY name, number WITH ROLLUP;
    

    Below Name column it would Display as Total. If you have issue with number as null same can be done for that too.

提交回复
热议问题