LoslegenKostenlos loslegen

Where are all the athletes from

The Olympics occurs every two years (Summer & Winter) and is an event that people worldwide watch. It sparks national pride as people root for athletes representing their own country. In this exercise, you will be looking at recent Olympic athletes data (2014 and 2016) to find which countries participated. You will need to join it to regional information that lists all countries who have ever participated in prior Olympics.

Here, you will join together the athletes and oregions tables to return countries with participating athletes.

Feel free to explore the data to see if you recognize any of the athletes from your own country.

Diese Übung ist Teil des Kurses

Improving Query Performance in PostgreSQL

Kurs anzeigen

Anleitung zur Übung

  • Join athletes to oregions using the country code.
  • Alias each table. Use ath for athletes and reg for oregions.
  • Check if you have any countries with no athletes.

Interaktive Übung

Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.

-- Athlete count by country and region
SELECT reg.region
  , reg.country
  , COUNT(DISTINCT ath.athlete_id) AS no_athletes -- Athletes can compete in multiple events
FROM ___ ___
___ ___ ___ ___
  ON reg.olympic_cc = ath.country_code
GROUP BY reg.region, reg.country
ORDER BY no_athletes;
Code bearbeiten und ausführen