All problems

Revenue Concentration

hardSQLSubqueriesArithmeticNULLs

Loopwire is considering a price change and the CFO wants to know how exposed the company is before anyone touches a number. MRR — monthly recurring revenue — is what a live contract bills each month. If one tier carries most of it, a mistake on that tier is a company-level event; if the revenue is spread evenly, the same mistake is a bad quarter. Raw dollar totals per tier do not answer that on their own — the CFO wants each tier's slice of the whole, as a percentage.

subscriptions — one row per contract. account_id points at a row in accounts. plan is the tier the customer bought. mrr is what that contract bills every month, in dollars. start_date is the day it began. A contract that has stopped carries the day it stopped in end_date; one that is still running has nothing there, shown as below and stored as NULL.

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
3 2 growth 149 2022-12-15 2023-06-15
4 3 starter 49 2023-01-31
5 4 growth 149 2023-02-06
6 5 enterprise 499 2023-02-22
7 6 starter 49 2023-03-01 2023-04-01
8 7 growth 149 2023-03-22
9 8 enterprise 499 2023-04-28
10 2 starter 49 2023-06-15

The table already exists in the database — there is nothing to create or load.

Task: Write a query that returns one row per plan that has at least one running contract, with columns plan and mrr_pct — that plan's share of the total monthly billing of all running contracts, as a percentage rounded to 1 decimal place. Stopped contracts are excluded from both the slice and the whole. Largest share first; equal shares are listed alphabetically by plan name.

Example output

Shape only — the tier names are the real ones, the figures are invented. A whole percentage comes back as 32, not 32.0:

plan mrr_pct
enterprise 55.4
starter 32
growth 12.6

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

Discussion

Sign in to join the discussion — reading is open to everyone.

Loading comments…