Only this week, get the SQL Complete Track of 9 courses in a special prize of $330$89!
Introduction
CUBE
Summary

## Instruction

Good! There is one more interesting modification of CUBE worth mentioning. Take a look:

SELECT
GROUPING_ID(Location, Gender, Risk) AS GroupingId,
Location,
Gender,
Risk,
AVG(Age) AS AvgAge
GROUP BY
CUBE ((Location, Gender), Risk);


Inside CUBE's parentheses, we put Location and Gender in another pair of parentheses! This means that Location and Gender will be treated as a single column — either both or neither of them will be used for grouping:

GROUP BY CUBE((Location, Gender), Risk) =
GROUP BY Location, Gender, Risk +
GROUP BY Location, Gender +
GROUP BY Risk +
GROUP BY ()


## Exercise

Run the template query. Note that each row is grouped by either Location and Gender together or by neither of these columns.