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

Instruction

Nice! If you need even more fine-grained control over the grouping combinations, you can also use multiple ROLLUPs:

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

The query above will create even more combinations than

ROLLUP(FullName, Category, Week)
because the grouping options of ROLLUP(FullName, Category) and the grouping options of ROLLUP(Week) are combined together. Take a look at the comparison:

LEAD

Exercise

Run the template query, to see how multiple ROLLUPs work.