GROUP BY Clause - Teradata Database

SQL Data Manipulation Language

Product
Teradata Database
Release Number
16.10
Published
June 2017
Language
English (United States)
Last Update
2018-04-25
dita:mapPath
psg1480972718197.ditamap
dita:ditavalPath
changebar_rev_16_10_exclude_audience_ie.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata® Database

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.
You cannot specify BLOB, CLOB, Period, ARRAY, VARRAY, XML, or JSON columns in the grouping expression.
ordinary_grouping_set falls into three general categories:
  • column_name
  • column_position
  • column_expression
See for the definitions of these expressions Ordinary Grouping Set Expressions.
empty_grouping_set
Contiguous LEFT PARENTHESIS, RIGHT PARENTHESIS pair without an argument. This syntax is used to request a grand total.
The term grand total here refers to a summation of all the individual group totals, not a summation of the nonaggregate data.
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”.
The expression cannot group result rows that have a BLOB, CLOB, ARRAY, or VARRAY type.
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”.
The expression cannot group result rows that have a BLOB, CLOB, ARRAY, or VARRAY type.
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.
For more information, see “GROUPING SETS Option”.

ANSI Compliance

The GROUP BY clause is ANSI SQL:2011-compliant with extensions.