Practice · Education · Medium
Using a CTE of university counts per city, return the single city with the most universities, with its count n. Break ties alphabetically.
Runs in your browser. No signup needed.
WITH cc AS (SELECT city, COUNT(*) AS n FROM universities GROUP BY city) then ORDER BY n DESC, city LIMIT 1.
WITH cc AS (
SELECT city, COUNT(*) AS n FROM universities GROUP BY city
)
SELECT city, n
FROM cc
ORDER BY n DESC, city
LIMIT 1;
The reference solution is checked automatically when you run your query on the practice page — results are compared row by row.
Cairo concentrates a large share of Egypt’s top universities — Cairo University, AUC, Ain Shams and Al-Azhar all sit in the capital. (QS 2026)