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

Instruction

Great! Of course, GROUPING SETS works with the GROUPING() function too:

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

Exercise

Find the average Interest amounts for the following grouping levels:

  • Year and Quarter
  • Country

Show the following columns in the query result: Year, Quarter, Country, AvgInterest, Y, Q, and C. The Y, Q, and C columns show if the columns Year, Quarter, and Country were used in the grouping.