FunctionRacerProblemsRace

Change From the Day Before

MediumSQLSQLite

prices has one closing price per day. Return every day and change: that day's close minus the close of the day before it in the table. The first day has no day before, so its change is NULL. Earliest day first.

Example 1

prices
dayclose
2026-01-05101.5
2026-01-02100.0
2026-01-0699.25
returns
daychange
2026-01-02NULL
2026-01-051.5
2026-01-06-2.25

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