Kickstart 2020 with new opportunities! - hours only!Up to 80% off on all courses and bundles.-Close
Introduction
GROUPING SETS
Summary

Instruction

Nice job!

What can we do with those NULL values? Naturally, we can use COALESCE():

SELECT
  date_received,
  customer_id,
  COALESCE(repair_center, 'ALL'),
  AVG(repair_duration) AS avg_repair_duration
FROM warranty_repair
GROUP BY GROUPING SETS
(
  (customer_id, repair_center),
  (date_received)
)

In the query above, any NULL values in the repair_center column will be replaced with the word ALL.

Exercise

Show the sum of all principal amounts for two grouping sets:

  1. sales_person
  2. country

Show the following columns in the query result: sales_person, country, and Sumprincipal.

Instead of NULL values in the columns sales_person and country, show a double dash (--).

Stuck? Here's a hint!

Start with:

SELECT
  COALESCE(sales_person, '--') AS sales_person