GROUPING function [Aggregate]

Identifies whether a column in a GROUP BY operation result set is NULL because it is part of a subtotal row, or NULL because of the underlying data.

Syntax
GROUPING( group-by-expression )
Parameters
  • group-by-expression   An expression appearing as a grouping column in the result set of a query that uses a GROUP BY clause. This function can be used to identify subtotal rows added to the result set by a ROLLUP or CUBE operation.

Return value
  • 1   Indicates that group-by-expression is NULL because it is part of a subtotal row. The column is not a prefix column for that row.

  • 0   Indicates that group-by-expression is a prefix column of a subtotal row.

See also
Standards and compatibility
  • SQL/2003   SQL foundation feature (T611) outside of core SQL.

Example

For examples of this function in use, see Detecting placeholder NULLs using the GROUPING function.