South African trends
You decide to zero in on one country to look at country demographic trends over time. Since 1990 (the first year of demographics' data), South Africa's population has increased from 37.5 to 56.7 million people. The GDP per capita has also increased from $6,267 to $13,497.
You want to determine if the number of Olympic athletes from South Africa has increased during this time.
The athletes
table is at an athlete-event level grain. You aggregate it to the year-country grain before joining it to the demographics_rank
table. Additionally, the demographics_rank
table is large, so you want to filter it to only South Africa before joining it to the athletes
data.
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 ___
, ___
, ___(___ ___) AS no_athletes
FROM athletes
WHERE country_code = ___
GROUP BY year, season;