Where to place a region filter
Population alone does not predict the number of Olympians. Researchers propose that gross domestic product (GDP) together with population can predict the number of Olympians. Luckily the World Bank also collects GDP per capita (GDP divided by the number of citizens) on many countries.
Focusing again on Africa, the most populous countries in 2014 were Nigeria, Ethiopia, and Egypt; however, the only African countries sending athletes to the 2014 Olympics were Morocco, Togo, and Zimbabwe.
Determine which African countries have 2014 GDP data and whether Morocco, Togo, and Zimbabwe have high GDPs.
This exercise is part of the course
Improving Query Performance in PostgreSQL
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
SELECT dem.olympic_cc, reg.country, dem.gdp, dem.population
FROM demographics dem
LEFT JOIN oregions reg
ON dem.olympic_cc = reg.olympic_cc
___ ___ = ___
WHERE dem.year = 2014
AND dem.gdp IS NOT NULL
ORDER BY dem.gdp DESC;