Introduction
GROUP BY – Recap
ROLLUP
Summary

Instruction

Perfect! You can see that by reversing the order of the columns inside the ROLLUP's parentheses, we changed one of the groupings.

As a general rule, ROLLUP will always show new grouping combinations by removing columns one by one, starting from the right:

GROUP BY ROLLUP (A, B, C) =
GROUP BY (A, B, C) +
GROUP BY (A, B) +
GROUP BY (A) +
GROUP BY ()

Okay, it's your turn now!

Exercise

Show how much was spent in each Category on each day, on each day in general, and in general among all days and categories. Show the following columns: Category, DeliveryDate, and the sum of TotalPrice (as Total).

Stuck? Here's a hint!

Use:

GROUP BY ROLLUP(DeliveryDate, Category)