Database · Hard
Explain GROUPING SETS, ROLLUP, and CUBE in SQL.
DatabaseSQLSenior
Answer preview
These extend GROUP BY to produce several levels of aggregation in one pass. GROUPING SETS lists the exact groupings you want, ROLLUP generates a hierarchical subtotal chain, and CUBE generates every possible combination — replacing multiple queries glued together with UNION ALL.…