Purpose
Groups result rows by the values in one or more columns or by various extended GROUP BY operations on specified column expressions.
Syntax
Syntax Elements
- GROUP BY
- Reference to one or more expressions in the select expression list.
- ordinary_grouping_set
- Column expression by which the rows returned by the statement are grouped.
- empty_grouping_set
- Contiguous LEFT PARENTHESIS, RIGHT PARENTHESIS pair without an argument. This syntax is used to request a grand total.
- rollup_list
- ROLLUP expression that reports result rows in a single dimension with one or more levels of detail. For more information, see “ROLLUP Grouping Set Option”.
- cube_list
- A CUBE expression that reports result rows in multiple dimensions with one or more levels of detail. For more information, see “CUBE Grouping Set Option”.
- grouping_sets_specification
- A GROUPING SETS expression that reports result rows in one of two ways:
- As a single dimension, but without a full ROLLUP.
- As multiple dimensions, but without a full CUBE.
ANSI Compliance
The GROUP BY clause is ANSI SQL:2011-compliant with extensions.