Practice · History · Easy
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.
pharaohs(name, reign_start, reign_end). Years are signed integers (negative = BCE), so the subtraction gives a positive length.
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.
Storing years as signed integers (BCE negative) makes date maths just… subtraction — no calendar library needed. (project convention)