- Categories:
Aggregate functions (General)
GROUPING¶
Describes which of a list of expressions are grouped in a row produced by a GROUP BY query.
- Aliases:
Syntax¶
Usage notes¶
GROUPING 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(
expr) returns 0 for a row that is grouped onexpr, and 1 for a row that is not grouped onexpr.GROUPING(
expr1,expr2, … ,exprN) returns the integer representation of a bit-vector containing GROUPING(expr1) , GROUPING(expr2) , … , GROUPING(exprN).
Examples¶
Group by sets:
Create and populate a table with values:
Show the values in the table:
Output: