CUBE Option | SQL SELECT Statements | Teradata Vantage - CUBE Option - Advanced SQL Engine - Teradata Database

SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
qtb1554762060450.ditamap
dita:ditavalPath
lze1555437562152.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantage™

Analyzes data by grouping it into multiple dimensions.

ANSI Compliance

CUBE is ANSI SQL:2011 compliant.

Rules and Restrictions for CUBE

You cannot specify a SAMPLE clause in a query that specifies the CUBE option in a GROUP BY clause, with the exception of a query where the CUBE option in the GROUP BY clause appears in a derived table or view and the SAMPLE clause appears in the outer query.

How CUBE Summarizes Data

Given n dimensions, CUBE generates 2n different kinds of groups. The database reports each group as a single row.

For example, with 2 dimensions, CUBE generates 4 groups as follows:

group number dimension 1 dimension 2
1 X X
2 X  
3   X
4    

With 3 dimensions, CUBE generates 8 groups as follows:

group number dimension 1 dimension 2 dimension 3
1 X X X
2 X X  
3 X   X
4 X    
5   X X
6   X  
7     X
8