简体   繁体   中英

Replacing cube with rollup in Oracle SQL

A homework assignment I have asks the following question:

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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM