Worst Drawdown
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
| day | close |
|---|---|
| 2026-01-02 | 100.0 |
| 2026-01-05 | 120.0 |
| 2026-01-06 | 90.0 |
| 2026-01-07 | 150.0 |
| 2026-01-08 | 135.0 |
returns
| drawdown |
|---|
| 25.0 |
Constraints
- 1 to 16 days, each day once
- Every
closeis above 0 - The result is not a close call for the rounding
Write it in your browser, against the clock. The model query, with a note on each piece of it, comes after.
More SQL problems
- Between Two PricesBeginner
- Both ConditionsBeginner
- Cheapest FirstBeginner
- Each Symbol OnceBeginner
- How Many SellsBeginner
- No ManagerBeginner
- One SymbolBeginner
- One of SeveralBeginner