CUBE Option | SQL SELECT Statements | VantageCloud Lake - CUBE Option - Teradata VantageCloud Lake

Lake - Working with SQL

Deployment
VantageCloud
Edition
Lake
Product
Teradata VantageCloud Lake
Release Number
Published
February 2025
ft:locale
en-US
ft:lastEdition
2025-11-21
dita:mapPath
jbe1714339405530.ditamap
dita:ditavalPath
pny1626732985837.ditaval
dita:id
jbe1714339405530

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