Practice · History · Medium
For UNESCO sites in a governorate we have population for, return the site and that governorate’s population_millions, most populous first.
Runs in your browser. No signup needed.
unesco_sites(site, governorate) joins governorates(name, population_millions) on governorate = name. An inner JOIN keeps only matches.
SELECT u.site, g.population_millions
FROM unesco_sites u
JOIN governorates g ON u.governorate = g.name
ORDER BY g.population_millions DESC;
The reference solution is checked automatically when you run your query on the practice page — results are compared row by row, and order matters for this one.
An inner join returns only rows that match on both sides — sites in governorates outside our slice simply drop out. (SQLite docs)