GDP per capita performance index
A performance index calculation is a good way to compare efficiency metrics across groups. A performance index compares each row to a benchmark.
To run a performance index calculation, take the following steps:
- Create a window function that outputs the performance for the entire partition.
- Run a ratio that divides each row's performance to the performance of the entire partition.
In this exercise, you will calculate the gdp_per_million
for each country relative to the entire world.
gdp_per_million = gdp / pop_in_millions
You will reference the country_stats_cleaned
table, which is a copy of country_stats
without data type issues.
This exercise is part of the course
Reporting in SQL
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
-- Bring in region, country, and gdp_per_million
SELECT
____,
____,
____ AS gdp_per_million
-- Pull from country_stats_clean
FROM ____ AS cs
JOIN ____ AS c
ON ____
-- Filter for 2016 and remove null gdp values
WHERE ____
GROUP BY ____
-- Show highest gdp_per_million at the top
ORDER BY ___;