开发者

Replacing cube with rollup in Oracle SQL

开发者 https://www.devze.com 2022-12-21 11:46 出处:网络
A homework assignment I have asks the following question: 开发者_JS百科Show how to express \\group by cube (a, b, c, d)\" using rollup rather than cube.

A homework assignment I have asks the following question:

开发者_JS百科Show how to express \group by cube (a, b, c, d)" using rollup rather than cube.

I really don't have the faintest clue how to do this. Where would I start or where could I look for some help?


Since this is an assignment I will point you to a very good article about GROUP BY, ROLLUP and CUBE by Rob van Wijk.

The two equivalence relations relevant here would be:

 GROUP BY CUBE ( set1, …, setn )
 ≡ GROUP BY GROUPING SETS (all possible combinations between () and (set1, …, setn) )

and the analogy with the cartesian product:

GROUP BY a, ROLLUP(b)
≡ GROUP BY GROUPING SETS (a), GROUPING SETS ((b), ())
≡ GROUP BY GROUPING SETS ((a,b), (a))
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号