FunctionRacerProblemsRace

Worst Drawdown

HardSQLSQLite

A drawdown is a fall from a peak: on any day, it is how far the close stands below the highest close seen up to that day, as a share of that highest close. Return one row with one column, drawdown: the largest such fall over the whole table, as a percentage rounded to 2 decimals. A price that never falls gives 0.

Example 1

prices
dayclose
2026-01-02100.0
2026-01-05120.0
2026-01-0690.0
2026-01-07150.0
2026-01-08135.0
returns
drawdown
25.0

Constraints

Race itor take your time

Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.

More SQL problems