Recall & Review
beginner
What does the ROLLUP operator do in a SQL query?
ROLLUP adds extra rows to the result set that show subtotals and a grand total for grouped data.
Click to reveal answer
intermediate
How does ROLLUP affect the GROUP BY clause?
ROLLUP extends GROUP BY by creating grouping sets that include all levels of aggregation from detailed groups up to a grand total.
Click to reveal answer
beginner
In MySQL, what value appears in the ROLLUP subtotal rows for the grouped columns?
The grouped columns in subtotal rows show NULL to indicate aggregation over all values in that column.
Click to reveal answer
beginner
Write a simple SQL query using ROLLUP to get sales totals by region and product.
SELECT region, product, SUM(sales) AS total_sales FROM sales_table GROUP BY region, product WITH ROLLUP;
Click to reveal answer
beginner
Why is ROLLUP useful in reports?
ROLLUP helps create reports that show detailed data plus subtotals and grand totals in one query, saving extra calculations.
Click to reveal answer
What does the ROLLUP operator add to a GROUP BY query?
✗ Incorrect
ROLLUP adds subtotal rows for each grouping level and a grand total row.
In a ROLLUP result, what does a NULL value in a grouped column mean?
✗ Incorrect
NULL indicates the subtotal or total row for that grouped column.
Which SQL clause is extended by ROLLUP?
✗ Incorrect
ROLLUP extends the GROUP BY clause to add subtotals and totals.
What keyword is used in MySQL to enable ROLLUP?
✗ Incorrect
MySQL uses WITH ROLLUP after GROUP BY to enable rollup subtotals.
If you GROUP BY region, product WITH ROLLUP, which row is NOT included?
✗ Incorrect
ROLLUP creates subtotals by region and grand total, but not subtotal by product alone.
Explain how the ROLLUP operator works in SQL and why it is useful for generating subtotals and totals.
Think about how ROLLUP adds extra rows to grouped results.
You got /4 concepts.
Write a SQL query using ROLLUP to show sales totals by two categories and explain the output rows you expect.
Use GROUP BY with two columns and WITH ROLLUP.
You got /4 concepts.