Skip to content

Instantly share code, notes, and snippets.

@phainamikaze
Created November 15, 2023 06:20
Show Gist options
  • Save phainamikaze/723247781fc1551af6445dccca13a364 to your computer and use it in GitHub Desktop.
Save phainamikaze/723247781fc1551af6445dccca13a364 to your computer and use it in GitHub Desktop.
Write a query to rank the countries in each region by their population from largest to smallest.
SELECT Region, Name, Population, RANK() over(partition by region ORDER BY population desc) as 'Ranked' FROM world.country ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment