Loading…
LAG(column, offset) returns the value from a previous row:
LAG(amount, 1) OVER(ORDER BY date) -- previous row's amount
LAG(amount, 2) OVER(ORDER BY date) -- 2 rows back
Default offset is 1 if not specified.
For each payment, show:
prev_amount)change_from_prev)Order by paidAt, limit to 10.
Downloading SQL engine… (one-time)
This runs entirely in your browser and is cached for next time.