Compare GROUPING_ID() to GROUPING()
statements #tsql#statements
Is a function that computes the level of grouping.
can be used only in the
list,
, or clauses when
is specified.
syntaxsql
A column_expression
in a
SELECT - GROUP BY clause.
The must exactly match the expression in the
list.
For example, if you’re grouping by
, use
; or if you’re grouping by
, use.
inputs the equivalent of the return for each column in its column list in each output row, as a string
Columns
aggregated
GROUPING_ID (a, b, c) input = GROUPING(a) +
GROUPING(b) + GROUPING(c)
GROUPING_ID() output
GROUPING_ID
GROUPING_ID
SELECT <select>
HAVING
ORDER BY
GROUP BY
GROUPING_ID <column_expression>
GROUP BY
DATEPART (yyyy, <column name>)
GROUPING_ID (DATEPART (yyyy, <column name>))
<column name>
GROUPING_ID (<column name>)
GROUPING_ID (<column_expression> [ ,.n ])
GROUPING (<column_expression>)
GROUPING
_
ID (
<column_expression>
[ ,.n ] )