Aan de slagGa gratis aan de slag

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:

  1. Create a window function that outputs the performance for the entire partition.
  2. 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.

Deze oefening maakt deel uit van de cursus

Reporting in SQL

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

-- 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 ___;
Code bewerken en uitvoeren