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

Instruction

Well done! Another thing you may be wondering about is whether you need to include all grouping columns inside the ROLLUP parentheses. No, you don't! You can leave some columns outside ROLLUP:

SELECT
 GROUPING_ID(FullName, Category, Week) AS GroupingId,
 FullName,
 Category, 
 Week,
 AVG(Score) AS AvgPrice
FROM ContestScore
GROUP BY 
  ROLLUP (FullName, Category),
  Week;

In the query above, all rows will be grouped by columns not included in ROLLUP. This means that the following grouping levels will be applied:

  1. GROUP BY FullName, Category, Week
  2. GROUP BY FullName, Week
  3. GROUP BY Week

Exercise

Run the template query and see what happens.