Details
-
Type:
Task
-
Status: Open (View Workflow)
-
Priority:
Major
-
Resolution: Unresolved
-
Fix Version/s: None
-
Component/s: Data Manipulation - Subquery
-
Labels:None
Description
MySQL 8 already allows this:
Using GROUPING() to substitute labels for the super-aggregate NULL values makes the result easier to interpret:
SELECT
IF(GROUPING(name) = 1, 'All items', name) AS name,
IF(GROUPING(size) = 1, 'All sizes', size) AS size,
SUM(quantity) AS quantity
FROM t1
GROUP BY name, size WITH ROLLUP;
This is an old feature of MsSQL. Over the years I have filed a few times a request so MariaDB fixes this problem because we cannot return nulls in the grouping cells, we need to add a meaningful label. Please stop procrastinating and listen to the business people. We cannot work efficiently as it is.
https://dev.mysql.com/doc/refman/8.0/en/group-by-modifiers.html