We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.

In addition to the regular aggregation results we expect from the GROUP BY clause, the ROLLUP extension produces group subtotals from right to left and a grand total.
Lets say you have table with two columns a,b.

a = 1,2

b = 3,4

Regular aggregation is will return 4 rows (2x2)

1,3

1,4

2,3

2,4

Rollup will return SUBTOTALS for every row from the right plus one subtotal for all rows (like sum on no aggregation) .
There would be 7 rows :

1,3

1,4

1,null

2,3

2,4

2,null

null,null

CUBE

In addition to the subtotals generated by the ROLLUP extension, the CUBE extension will generate subtotals for all combinations of the dimensions specified. If "n" is the number of columns listed in the CUBE, there will be 2n subtotal combinations.

Lets say you have table with two columns a,b.

a = 1,2

b = 3,4

Cube will return SUBTOTALS for every row in every direction plus one subtotal for all rows (like sum on no aggregation) .
There would be 9 rows :

## OLAP Operation Types

You are viewing a single comment's thread. Return to all comments →

ROLLUP

In addition to the regular aggregation results we expect from the GROUP BY clause, the ROLLUP extension produces group subtotals from right to left and a grand total. Lets say you have table with two columns a,b.

a = 1,2

b = 3,4

Regular aggregation is will return 4 rows (2x2)

1,3

1,4

2,3

2,4

Rollup will return SUBTOTALS for every row from the right plus one subtotal for all rows (like sum on no aggregation) . There would be 7 rows :

1,3

1,4

1,null

2,3

2,4

2,null

null,null

CUBE

In addition to the subtotals generated by the ROLLUP extension, the CUBE extension will generate subtotals for all combinations of the dimensions specified. If "n" is the number of columns listed in the CUBE, there will be 2n subtotal combinations.

Lets say you have table with two columns a,b.

a = 1,2

b = 3,4

Cube will return SUBTOTALS for every row in every direction plus one subtotal for all rows (like sum on no aggregation) . There would be 9 rows :

1,3

1,4

1,null

2,3

2,4

2,null

null,3

null,4

null,null

Thanks Aldo.

Can you please relate this to the actual problem and help me to understand how it comes to the solution D (4,7,3,84,160,117).

Appreciate your time..

No problem, sorry for the late reply. The tuple must satisfy the equation :

a,b,c,

/* Aggregation number of rows */ a*b*c,

/* Cube number of rows */ a*b*c+a*b+b*c+a*c+a+b+c+1,

/* Rollup number of rows */ a*b*c+a+a*b+1

And only one answers satisfies this.

Hello Aldo,

This is really helpful to understand,However I have one question about Rollup tuples count:- Intstead of a*b*c+a+a*b+1,it should be ,a*b*c+a+b+c+1

I think it goes from smaller combination to bigger, like this:

/* Aggregation */ (a*b*c),

/* Cube */ 1+a+b+c+(a*b)+(b*c)+(c*a)+(a*b*c),

/* Rollup */ 1+a+(a*b)+(a*b*c)