Get startedGet started for free

Country-level subtotals

You want to look at three Scandinavian countries' earned gold medals per country and gender in the year 2004. You're also interested in Country-level subtotals to get the total medals earned for each country, but Gender-level subtotals don't make much sense in this case, so disregard them.

This exercise is part of the course

PostgreSQL Summary Stats and Window Functions

View Course

Exercise instructions

  • Count the gold medals awarded per country and gender.
  • Generate Country-level gold award counts.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

-- Count the gold medals per country and gender
SELECT
  ___,
  ___,
  COUNT(*) AS Gold_Awards
FROM Summer_Medals
WHERE
  Year = 2004
  AND Medal = 'Gold'
  AND Country IN ('DEN', 'NOR', 'SWE')
-- Generate Country-level subtotals
GROUP BY ___, ___
ORDER BY Country ASC, Gender ASC;
Edit and Run Code