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 :
1,3
1,4
1,null
2,3
2,4
2,null
null,3
null,4
null,null
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
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