Practice · Demographics · Medium

Longest governorate names (LENGTH)

Return the 5 governorates with the longest names: name and its LENGTH as len, longest first (ties by name).

Runs in your browser. No signup needed.

What you are given

Use the LENGTH(name) function.

Starting point

SELECT name, LENGTH(name) AS len
FROM governorates
ORDER BY len DESC, name
LIMIT 5;

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

String functions like LENGTH, UPPER, LOWER, SUBSTR and TRIM are everyday tools for cleaning messy text data. (SQLite docs)

More Demographics challenges

Open it in the playground →