← All SQL interview questions

Running revenue total by month

MediumWindow FunctionsRazorpayPayPal

Finance publishes a cumulative revenue line for each product line across 2026.

From monthly_revenue, return product_line, revenue_month, revenue and running_total — the cumulative revenue for that product line from the earliest month up to and including the current month.

Sample data

Table: monthly_revenue

16 row(s) · showing first 8

row_idINTproduct_lineTEXTrevenue_monthDATErevenueNUMERIC(12,2)
1Payments2026-01-01420000.00
2Payments2026-02-01388000.00
3Payments2026-03-01465000.00
4Payments2026-04-01502000.00
5Lending2026-01-01180000.00
6Lending2026-02-01225000.00
7Lending2026-03-01198000.00
8Lending2026-04-01260000.00