Aan de slagGa gratis aan de slag

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.

Deze oefening maakt deel uit van de cursus

PostgreSQL Summary Stats and Window Functions

Cursus bekijken

Oefeninstructies

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

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

-- 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;
Code bewerken en uitvoeren