GROUPING_ID
functionsupportedCore SQL functionsDescribes which of a list of expressions are grouped in a row produced by a GROUP BY query. Alias for GROUPING.
Syntax
supportedpartialnot supportednot scored
GROUPING_ID( <expr1> [ , <expr2> , ... ] )
Usage notes
- GROUPING_ID is not an aggregate function, but rather a utility function that can be used alongside aggregation, to determine the level of aggregation a row was generated for:
- GROUPING_ID(expr) returns 0 for a row that is grouped on expr, and 1 for a row that is not grouped on expr.
- GROUPING_ID(expr1, expr2 , … , exprN) returns the integer representation of a bit-vector containing GROUPING_ID(expr1) , GROUPING_ID(expr2) , … , GROUPING_ID(exprN).