What are GROUPING SETS, ROLLUP and CUBE?

SQL aggregates and GROUP BY · Experienced

Model answer

Extensions to GROUP BY to produce several levels of subtotals in one query. ROLLUP gives hierarchical subtotals and a grand total, CUBE gives all combinations, and GROUPING SETS lets you list the exact groupings. Support varies by database, so check yours.

Learn this topic

GROUP BY and HAVING: Summaries for Each Group in the course SQL for Beginners: Learn Databases Step by Step.

Sign in to add your own answer.

More questions