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 |