Skip to main content
Version: Latest-4.0

grouping_id

grouping_id is used to distinguish the grouping statistics results of the same grouping standard.

Syntax​

GROUPING_ID(expr)

Examples​

MySQL > SELECT COL1,GROUPING_ID(COL2) AS 'GroupingID' FROM tbl GROUP BY ROLLUP (COL1, COL2);
+------+------------+
| COL1 | GroupingID |
+------+------------+
| NULL | 1 |
| 2.20 | 1 |
| 2.20 | 0 |
| 1.10 | 1 |
| 1.10 | 0 |
+------+------------+
StarRocks Assistant

AI generated answers are based on docs and other sources. Please test answers in non-production environments.