FunctionRacerProblemsRace

Longest Winning Streak

HardSQLSQLite

results has one row per trading day with that day's profit or loss, pnl. A winning day has pnl above 0. Return one row with one column, longest: the largest number of winning days in a row, taking the days in date order. With no winning day at all it is 0.

Example 1

results
daypnl
2026-01-025
2026-01-057
2026-01-06-2
2026-01-071
2026-01-084
2026-01-099
2026-01-120
returns
longest
3

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