MySQL only get overall ROLLUP

后端 未结 3 532
轻奢々
轻奢々 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条回答
  •  逝去的感伤
    2021-01-20 03:03

    Try to use a subquery, e.g. -

    SELECT * FROM (
      SELECT name, number, COUNT(1) FROM test GROUP BY name, number WITH ROLLUP) t
    WHERE name IS NULL OR number IS NULL
    

    You also may want to change NULL values with appropriate texts.

提交回复
热议问题