All group-level subtotals
You want to break down all medals awarded to Russia in the 2012 Olympic games per gender and medal type. Since the medals all belong to one country, Russia, it makes sense to generate all possible subtotals (Gender- and Medal-level subtotals), as well as a grand total.
Generate a breakdown of the medals awarded to Russia per country and medal type, including all group-level subtotals and a grand total.
Questo esercizio fa parte del corso
PostgreSQL Summary Stats and Window Functions
Istruzioni dell'esercizio
- Count the medals awarded per gender and medal type.
- Generate all possible group-level counts (per gender and medal type subtotals and the grand total).
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
-- Count the medals per gender and medal type
SELECT
___,
___,
___ AS Awards
FROM Summer_Medals
WHERE
Year = 2012
AND Country = 'RUS'
-- Get all possible group-level subtotals
GROUP BY ___
ORDER BY Gender ASC, Medal ASC;