BigQuery SQL for transforming subscription data into customer-level MRR movements and a reconciled monthly bridge.
For a short explanation of the model and its scope, see the MRR Bridge SQL resource on MRRWorks.
This project is for data and analytics engineers building revenue models for subscription businesses.
It assumes an existing SQL warehouse and subscription data from Stripe or a similar billing source. The demo uses synthetic, Stripe-shaped data; adapt the input relation to your warehouse schema.
- Customer-month MRR
- Per-customer MRR movement classifications
- A monthly MRR bridge
- A reconciliation check
Movement classifications include New Business, Expansion, Contraction, Churn, Reactivation, and Unchanged.
- Open BigQuery.
- Copy
demo.sqlinto a query. - Run it.
- Confirm that the output
reconcilescolumn isTRUE.
The demo data is inlined. It requires no source tables, credentials, or setup, and processes zero source bytes.
The query expects subscription records with these fields:
| Field | Description |
|---|---|
customer_id |
Stable customer identifier |
subscription_id |
Stable subscription identifier |
started_at |
Subscription start date |
ended_at |
Subscription end date, if ended |
unit_amount |
Recurring price per unit in the source currency |
quantity |
Quantity or seat count |
interval |
Billing interval, currently month or year |
Replace the demo subscriptions CTE with a relation from your warehouse. The query is written for BigQuery Standard SQL.
The query builds these models as CTEs and returns mrr_summary as its final result:
customer_month_mrr: one row per customer and month, including zero-MRR months needed to show churn.mrr_movement: one row per customer and month with the movement classification and amount.mrr_summary: the monthly bridge from opening MRR to closing MRR, including the reconciliation check.
- Monthly MRR is the recurring subscription amount normalized to a monthly value. Annual plans are divided by 12.
- New Business is the first positive MRR for a customer.
- Expansion is an increase from one positive customer-month to the next.
- Contraction is a decrease while the customer remains active.
- Churn is a change from positive MRR to zero.
- Reactivation is a return to positive MRR after a prior churn.
- Unchanged is a movement below the configured materiality threshold.
Assumptions are grouped in the policy CTE at the top of demo.sql. The current defaults are:
- A customer-month without active subscription MRR is treated as zero.
- Changes below
0.01are treated as no change. - Amounts are rounded to two decimal places before comparison.
- The demo uses an explicit as-of date so its result is reproducible.
Review these decisions before adapting the query to production data.
This is a SQL starting point, not a complete Stripe connector or dbt package. It does not fetch data from Stripe, define a warehouse ingestion process, or cover every billing configuration.
Before production use, validate the model against your subscription schema and business rules, including trials, discounts, taxes, credits, refunds, multiple subscription items, currency handling, backdated changes, pauses, and cancellations.
Early release. The self-contained demo is runnable and includes a reconciliation check. Split warehouse models, real Stripe-replica inputs, and broader test coverage are planned.
Apache-2.0. See LICENSE.