17.05 - group_specification - Advanced SQL Engine - Teradata Database

Teradata Vantage™ - SQL Data Definition Language Syntax and Examples

Product
Advanced SQL Engine
Teradata Database
Release Number
17.05
Release Date
January 2021
Content Type
Programming Reference
Publication ID
B035-1144-175K
Language
English (United States)
GROUP BY
An introduction to an optional reference to one or more expressions in the select expression list used to group rows in the results set.
ordinary_grouping_set
A column expression by which the rows returned by the request are grouped.
You cannot include BLOB, CLOB, UDT, Period, or Geospatial columns in the grouping expression.
You can group by:
  • column_name

    A set of column names drawn from the list of tables specified in the FROM clause of the SELECT request that is used in the GROUP BY clause to specify the columns by which data is to be grouped.

    See Teradata Vantage™ - SQL Fundamentals, B035-1141 for the rules for naming database objects.

  • column_position

    The sequential numeric position of columns within the column_list clause of the SELECT statement that is used in the GROUP BY clause to specify the order by which data is to be grouped.

    The sequential numeric position of columns within the column_list clause of the SELECT statement that is used in the GROUP BY clause to specify the order by which data is to be grouped.

    This must be a positive integer.

    Use of column_position is a Teradata extension to the ANSI SQL-2011 standard.

  • expression

    Any list of valid SQL expressions specified for the GROUP BY clause.

    You can specify column_name, column_position, and expression either as individual entries or as a list.

    Use of expression is a Teradata extension to the ANSI SQL-2011 standard.

    For details about ordinary grouping sets, see SQL Data Manipulation Language.

empty_grouping_set
A contiguous LEFT PARENTHESIS, RIGHT PARENTHESIS pair with no argument. In general, this syntax is used to request a grand total.
rollup_list
A ROLLUP expression that reports result rows in a single dimension with one or more levels of detail. See Teradata Vantage™ - SQL Data Manipulation Language, B035-1146 for further information.
cube_list
A CUBE expression that reports result rows in multiple dimensions with one or more levels of detail. See Teradata Vantage™ - SQL Data Manipulation Language, B035-1146 for further information.
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.
See Teradata Vantage™ - SQL Data Manipulation Language, B035-1146 for further information.