Practice · Demographics · Medium

Population density

Return name and population density (people per km²) as ROUND(population_millions × 1000000 / area_km2, 0) aliased as density, densest first. Note how desert governorates rank low.

Runs in your browser. No signup needed.

What you are given

governorates(name, population_millions, area_km2). Density = people ÷ area.

Starting point

SELECT name,
       ROUND(population_millions * 1000000 / area_km2, 0) AS density
FROM governorates
ORDER BY density 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.

Did you know

Qalyubia and Cairo are among the densest places on Earth, while vast desert governorates like Minya look sparse on paper — density reveals what a raw population count hides.

More Demographics challenges

Open it in the playground →