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

Instruction

Good job! Now, if we want to reduce the number of grouping combinations, we can exclude some columns from CUBE:

SELECT
  location,
  gender,
  risk,
  MIN(efficacy) AS min_efficacy
FROM vaccine_administration
GROUP BY 
  CUBE (location, gender), risk;

In the query above, CUBE will create grouping combinations for location and gender, but risk will be added to each grouping combination. As a result, we’ll get the following levels:

GROUP BY CUBE (location, gender), risk =
GROUP BY location, gender, risk +
GROUP BY location, risk +
GROUP BY gender, risk +
GROUP BY risk

Exercise

Run the template query and note that risk is now always used for grouping.