Practice · History · Medium

How long the queens held power

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.

What you are given

royal_women(name, period_start, period_end). Both are signed years and are NULL when not firmly fixed.

Starting point

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.

Did you know

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)

More History challenges

Open it in the playground →