How Much New Revenue Started in Each Month?
Loopwire reports one number to its board every month: how much recurring revenue started that month. Finance wants the whole series rather than a single figure, so the board can see the shape of the year instead of the last point on it.
Each subscription row is a contract. mrr is what that contract bills every month, and start_date is the day it began — so a subscription counts towards exactly one month, the month it started, no matter how long it then ran or whether it has since ended. A subscription that has already ended still counts towards the month it began in.
Two details will decide whether your series matches theirs. Nothing in this database is stored per month; each row carries a full date. And 2023 has a month in which no subscription started at all.
subscriptions — one row per subscription contract. mrr is the monthly recurring revenue that contract bills, in dollars. end_date is NULL while the contract is still running.
| id | account_id | plan | mrr | start_date | end_date |
|---|---|---|---|---|---|
| 1 | 1 | starter | 49 | 2022-11-03 | 2023-02-03 |
| 2 | 1 | growth | 149 | 2023-02-03 | NULL |
| 3 | 2 | growth | 149 | 2022-12-15 | 2023-06-15 |
| 4 | 3 | starter | 49 | 2023-01-31 | NULL |
| 5 | 4 | growth | 149 | 2023-02-06 | NULL |
| 6 | 5 | enterprise | 499 | 2023-02-22 | NULL |
| 7 | 6 | starter | 49 | 2023-03-01 | 2023-04-01 |
| 8 | 7 | growth | 149 | 2023-03-22 | NULL |
| 9 | 8 | enterprise | 499 | 2023-04-28 | NULL |
| 10 | 2 | starter | 49 | 2023-06-15 | NULL |
The table already exists in the database — there is nothing to create or load.
Task: Write a query returning two columns, start_month and new_mrr. start_month is the calendar month a subscription began, as text in YYYY-MM form. new_mrr is the total mrr of every subscription that began in that month. There is one row for each month in which at least one subscription started, and no row at all for a month in which none did. Every subscription counts once, whether or not it has since ended. Rows come back sorted by start_month, earliest first.
Example output — shape only, on an invented year. Note the month format: 2021-05, not May and not 5.
| start_month | new_mrr |
|---|---|
| 2021-05 | 129 |
| 2021-07 | 348 |
| 2021-10 | 79 |
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in