Practice · History · Easy

How long did they reign?

Return the 5 longest-reigning pharaohs: name and years reigned (reign_end − reign_start) as years, longest first.

Runs in your browser. No signup needed.

What you are given

pharaohs(name, reign_start, reign_end). Years are signed integers (negative = BCE), so the subtraction gives a positive length.

Starting point

SELECT name, reign_end - reign_start AS years
FROM pharaohs
ORDER BY years DESC
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

Storing years as signed integers (BCE negative) makes date maths just… subtraction — no calendar library needed. (project convention)

More History challenges

Open it in the playground →