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

Instruction

Great! Now it's your turn to write a similar query.

Try this exercise!

Exercise

Find the average principal amounts for the following two grouping combinations:

  1. Year and Quarter
  2. Country

Show the following columns in the query result: Year, Quarter, Country, and AvgPrincipal.

Stuck? Here's a hint!

Use this template to help you:

SELECT
  A,
  NULL AS B,
  ...
FROM X
GROUP BY A
UNION ALL
SELECT
  NULL AS A,
  B,
  ...
FROM X
GROUP BY B