Window function: running SUM over a date bucket.
For each month (YYYY-MM), return total monthly revenue AND the running total of revenue from the beginning of the data up through that month. Columns: `month`, `monthly_revenue`, `running_total`. Order by month. Table: `ci_orders`.
| Column | Type | Key |
|---|---|---|
| order_id | INT | PK |
| customer_id | INT | |
| product_name | TEXT | |
| category | TEXT | |
| order_date | DATE | |
| revenue | NUMERIC |
Each hint you reveal reduces the XP you can earn. Try the query first.
TO_CHAR(DATE_TRUNC('month', order_date), 'YYYY-MM') for the month label.
SUM(SUM(revenue)) OVER (ORDER BY DATE_TRUNC('month', order_date)) for the running total.