Introduction
CUBE
Summary

Instruction

Great! Lastly, the function COALESCE() can be used in the SELECT clause to replace NULL values with the values of your choice:

SELECT
  GROUPING_ID(Location, Gender, Risk) AS GroupingId,
  COALESCE(Location, '--') AS Location,
  COALESCE(Gender, '--') AS Gender,
  COALESCE(Risk, '--') AS Risk,
  AVG(Age) AS AvgAge
FROM VaccineAdministration
GROUP BY 
  CUBE (Location, Gender, Risk);

In the query above, '--' will be shown when Location, Gender, or Risk is NULL.

Exercise

Run the template query and note how NULLs are replaced with '--'.