Practice · History · Medium
For royal women with both dates recorded, return name and years_in_power (period_end − period_start), longest first.
Runs in your browser. No signup needed.
royal_women(name, period_start, period_end). Both are signed years and are NULL when not firmly fixed.
SELECT name, (period_end - period_start) AS years_in_power
FROM royal_women
WHERE period_start IS NOT NULL
AND ...
ORDER BY ...;
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.
Several of the most powerful royal women have no firm dates at all — Tiye and Nefertari are dated only through their husbands. (Have Fun With History)