Real-world recipes · SaaS finance
Monthly recurring revenue (MRR) by month
MRR on a date is the sum of mrr for every subscription that was active on that date: started on or before it, and not cancelled yet.
First we need a list of months to measure. WITH RECURSIVE builds one: start at January and keep adding a month until June. Then we join each month-end to the subscriptions active on it.
Try itEdit the query, then Run
| month | mrr | paying_customers |
|---|---|---|
| 2026-01 | 1249 | 21 |
| 2026-02 | 3229 | 61 |
| 2026-03 | 6977 | 123 |
| 2026-04 | 9251 | 149 |
| 2026-05 | 12244 | 196 |
| 2026-06 | 16481 | 249 |
6 rows
The WITH part is a temporary table that lives only for this query. It's the SQL version of a helper sheet.
Your turn
Simpler check: what is MRR today, meaning the sum of mrr for subscriptions with no cancelled_at? Call it current_mrr.
WHERE cancelled_at IS NULL, then SUM(mrr).
This page on one card
