Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
GROUP BY – Recap
ROLLUP
Summary

Instruction

Excellent. Now, you may have noticed that when we wrote:

SELECT
  FullName,
  Category, 
  AVG(Score) AS AvgScore
FROM ContestScore
GROUP BY ROLLUP (FullName, Category);

we got the following groupings:

  1. Average by FullName and Category
  2. Average by FullName
  3. Overall average

In other words, we saw the FullName average, but we didn't see an average for Category only. That's because the column order matters in ROLLUP. Let's check that out.

Exercise

Run the template query. Note that the order of columns inside the parentheses of ROLLUP has been reversed.

As you can see, we now have the following groupings:

  1. Average by FullName and Category
  2. Average by Category
  3. Overall average