GROUPING

Indicates whether a specified column expression in a GROUP BY list is aggregated or not. GROUPING returns 1 for aggregated or 0 for not aggregated in the result set. GROUPING can be used only in the SELECT <select> list, HAVING, and ORDER BY clauses when GROUP BY is specified.

Syntax

GROUPING ( <column_expression> )

Arguments

Is a column or an expression that contains a column in a GROUP BY clause.

Return types

tinyint

Examples

SELECT GROUPING([Id]) AS [Grouping] FROM [BasicDataTable] GROUP BY [Id] WITH ROLLUP

See Also