Practice · History · Hard

The removals, cumulatively

For obelisks with a recorded year_moved, return name, current_city, year_moved and moved_to_date — a running count of how many had been moved up to and including that year — earliest first.

Runs in your browser. No signup needed.

What you are given

obelisks(name, current_city, year_moved). Use a running COUNT(*) OVER (ORDER BY year_moved).

Starting point

SELECT name, current_city, year_moved,
       COUNT(*) OVER (ORDER BY ...) AS moved_to_date
FROM obelisks
WHERE year_moved IS NOT NULL
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

The removals cluster in the nineteenth century, when European powers treated Egyptian monuments as diplomatic gifts. (Wikipedia, Egyptian obelisks)

More History challenges

Open it in the playground →