FunctionRacerProblemsRace

Moving Average

HardSQLSQLite

prices has one closing price per day. Return every day with ma3: the average of that day's close and the closes of the two rows before it, rounded to 2 decimals. The first day averages one price and the second day two. Earliest day first.

Example 1

prices
dayclose
2026-01-0210.0
2026-01-0520.0
2026-01-0660.0
2026-01-0710.0
returns
dayma3
2026-01-0210.0
2026-01-0515.0
2026-01-0630.0
2026-01-0730.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