Aggregating and sorting populations
You are interested in planning your next vacation. You think it would be fun to visit a country that has changed a lot in recent years. You figure one way to look at change is to look at a change in population. So you focus on countries with big changes in population over the past 25 years.
You have annual population data from the World Bank covering each year from 1990 to 2017. Find the countries with the biggest population changes. Check your query plan to see how the aggregations impact the plan.
Cet exercice fait partie du cours
Improving Query Performance in PostgreSQL
Exercice interactif pratique
Essayez cet exercice en complétant cet exemple de code.
SELECT country
, region
, MAX(population) - MIN(population) as population_change
FROM country_pop
GROUP BY ___, ___;