Aan de slagGa gratis aan de slag

Filtering in the join, where, and select

Looking at all the countries with gross domestic product (GDP) data in 2014, the average GDP per capita was $19,342. For African countries, the average GDP per capita was $5,879.

Perhaps the African countries that sent athletes to the Olympics (Morocco, Togo, Zimbabwe) did not have the highest GDPs per capita in Africa but had higher GDPs than the average African GDP.

Test this theory. Find the per capita GDP for the African countries with athletes at the 2014 Winter Games.

Deze oefening maakt deel uit van de cursus

Improving Query Performance in PostgreSQL

Cursus bekijken

Oefeninstructies

  • The athletes' data is already limited to African competitors. Find the unique athletes from the athletes_wint table.
  • Use the JOIN to filter the athletes to only those with odemographic (GDP) data.
  • Use a year filter from the athletes_wint table to restrict results to only the 2014 athletes.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

SELECT ___ ath.name, dem.country, dem.gdp
FROM athletes_wint ath
___ ___ odemographics dem
  ON ath.country_code = dem.olympic_cc 
___ ___ = ___
ORDER BY dem.gdp DESC;
Code bewerken en uitvoeren