GROUPING SETS vs ROLLUP vs CUBE in SQL: what groupings does each produce, and when do you use each?
Role: Data Scientist
Category: Data Manipulation (SQL/Python)
Difficulty: medium
Interview Round: Other
Overview: Asks what GROUPING SETS, ROLLUP and CUBE do in SQL, which aggregate groupings each one produces, and when to use each. Tests understanding of subtotals and grand totals, how the number of groupings grows with the column list, and how to label subtotal rows in the result.