Practice · History · Easy

The five longest reigns

Rank pharaohs by reign length (reign_end − reign_start) and return the top 5 as name and years_reigned, longest first.

Runs in your browser. No signup needed.

What you are given

pharaohs(name, reign_start, reign_end). Years are signed, so reign_end − reign_start gives a positive length.

Starting point

SELECT name, (reign_end - reign_start) AS years_reigned
FROM pharaohs
ORDER BY ...
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

Pepi II tops the list at a traditional 94 years — but several Egyptologists argue for ~64. The knowledge base flags this dispute rather than picking a side. (Turin King List; Wikipedia)

More History challenges

Open it in the playground →