Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
GROUPING SETS
Summary

Instruction

Well done! Let's say we also need to add the general average repair duration to our report. To that end, we can use an empty pair of parentheses:

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

As you can see, we can omit the parentheses for single statments – like DateReceived in this case.

Exercise

Run the template query. As you can see, a row with a general average was added.