UPDATESQL

Unit 20 · Window functions

Running totals with window functions

Monthly revenue with a running total

A window function calculates across a set of rows without collapsing them. SUM(x) OVER (ORDER BY month) adds up every row up to the current one, giving a running total next to each month.

Example
SELECT order_date,
       SUM(1) OVER (ORDER BY order_date) AS orders_so_far
FROM orders;

Your task

Finance wants 2026 delivered revenue by month, plus a running total so they can see progress toward the annual target.

Months should come out as text like '2026-03'.

Tables you will use: orders, order_items

Try it in your browserFree, no sign-up. Your query is checked as you go.