Introduction
GROUPING SETS
Summary

Instruction

Good job! One more interesting thing we can do with GROUPING SETS is combine them with ROLLUP or CUBE:

SELECT
  GROUPING_ID(DateReceived, CustomerId, RepairCenter) AS GroupingId,
  DateReceived,
  CustomerId,
  RepairCenter,
  AVG(RepairDuration) AS AvgRepairDuration
FROM WarrantyRepair
GROUP BY GROUPING SETS
(
  ROLLUP (CustomerId, RepairCenter),
  (DateReceived)
)

The query above will merge ROLLUP grouping levels with a grouping level based on DateReceived. As a result, we'll get the following grouping combinations:

LEAD

Exercise

Run the template query and note how many grouping levels are created.