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

Instruction

Nice job! CUBE creates all possible grouping combinations, which also means we get all possible GROUPING_ID() values for the given number of columns (i.e., all values from 0 to 7 for three columns).

It’s your turn now!

Exercise

Show the maximum wildfire duration for all possible grouping combinations of the following columns: Year, Month, and Cause.

Show the following columns in the query result: GroupingId (depending on Year, Month, and Cause respectively), Year, Month, Cause, and MaxDuration.

Order the results by the GroupingId so that related rows are close to each other.

Stuck? Here's a hint!

Use the following template:

SELECT
  GROUPING_ID(x, y, z) AS GroupingId,
  ...
FROM ...
GROUP BY 
  CUBE (x, y, z)
ORDER BY GROUPING_ID(x, y, z)