Blog / Measuring in PostHog and Stripe
Stripe Sigma: reading your MRR and churn in SQL, with queries
Stripe Sigma runs SQL on your Stripe data inside the Dashboard. Four queries for MRR movements, churn rate, MRR by product and recently churned customers.
Stripe Sigma is an SQL editor inside the Stripe Dashboard that queries your own Stripe data: payments, subscriptions, customers, invoices. For a SaaS, its most useful table is subscription_item_change_events, which records every change to a subscription that moved MRR. The four queries below turn that table into monthly MRR movements, a churn rate, MRR by product and a list of churned customers to call, and the last section says when the Billing dashboard is enough.
What Stripe Sigma is, and what it costs
Stripe's How Sigma works page describes it as an interactive SQL environment in the Dashboard. The data is read-only: a query can never change a subscription or create a charge. The query editor docs give the working limits:
- Queries are written in "standard ANSI SQL." Stripe's own examples use functions such as
date_trunc,count_ifand window functions, which all work below. - The editor shows at most 1,000 result rows, and charts need fewer than 10,000. The CSV download "includes all query results."
- Amounts are "expressed in the lowest available currency unit," so 1000 in
usdmeans $10. Every query here divides by 100 for that reason, which is wrong for zero-decimal currencies such as JPY. - A built-in LLM assistant writes or edits SQL from a plain-language prompt. It "responds only to questions in English" and only about the Stripe schema.
- Saved queries can be scheduled daily, weekly or monthly, with results sent by email or by a
sigma.scheduled_query_run.createdwebhook event.
On price, the Sigma pricing page bills by the number of successful charges per month, with a monthly plan, a cheaper annual plan and a fee per charge above your tier. New users get a 30-day free trial, and Sigma is free without usage limit in test environments. Prices differ by country, so read the page for your account's country before you subscribe.
The table that holds your MRR
The billing data docs describe subscription_item_change_events as the table for MRR. Each row is one change to one subscription item, with these columns among others: customer_id, subscription_id, product_id, price_id, currency, event_type, mrr_change, quantity_change, event_timestamp (UTC) and local_event_timestamp (your account's time zone).
The event_type values:
| Event type | Meaning, per Stripe |
|---|---|
| ACTIVE_START | The item started contributing to MRR |
| ACTIVE_END | The item stopped contributing to MRR |
| ACTIVE_UPGRADE | The item's MRR went up (higher price or quantity) |
| ACTIVE_DOWNGRADE | The item's MRR went down |
| ACTIVE_QUANTITY_INCREASE | Quantity went up without changing MRR (tiered pricing) |
| ACTIVE_QUANTITY_DECREASE | Quantity went down without changing MRR |
Two details decide whether your numbers are right.
First, event_type describes one subscription item, and churn happens at the customer level. A customer who cancels one of two subscriptions produces an ACTIVE_END on the item, but for your churn rate that customer contracted. Stripe's own example query handles this by summing each customer's mrr_change over time and classifying the movement of that running total. The queries below do the same.
Second, freshness. Stripe says this table carries more recent data than the source of the Billing overview's MRR charts, so yesterday and today can differ from the Dashboard. A newer subscription_item_change_events_v2_beta table, in public preview, adds trial events and a customer-level event type, and keeps "a 3 hour freshness in Sigma." Its recent rows can still be revised: Stripe advises waiting up to 48 hours for data to settle before using it incrementally. Every query below runs on either table: add the _v2_beta suffix to switch.
Query 1: MRR movements by month
This is the query to schedule monthly. It returns, for each month, new, expansion, contraction, churned and reactivated MRR, plus ending MRR, in one currency.
-- MRR movements by month, one currency, in dollars
WITH events AS (
SELECT
customer_id,
local_event_timestamp,
sum(mrr_change) AS mrr_change
FROM subscription_item_change_events
WHERE currency = 'usd'
GROUP BY 1, 2
),
running AS (
SELECT
customer_id,
local_event_timestamp,
mrr_change,
sum(mrr_change) OVER (
PARTITION BY customer_id ORDER BY local_event_timestamp
) AS mrr_after,
count(nullif(mrr_change, 0)) OVER (
PARTITION BY customer_id ORDER BY local_event_timestamp
) AS mrr_changes_so_far
FROM events
),
classified AS (
SELECT
customer_id,
local_event_timestamp,
date_trunc('month', local_event_timestamp) AS month,
mrr_change,
CASE
WHEN mrr_after - mrr_change = 0 AND mrr_after > 0
AND mrr_changes_so_far = 1 THEN 'new'
WHEN mrr_after - mrr_change = 0 AND mrr_after > 0 THEN 'reactivation'
WHEN mrr_after = 0 AND mrr_after - mrr_change > 0 THEN 'churn'
WHEN mrr_change > 0 THEN 'expansion'
WHEN mrr_change < 0 THEN 'contraction'
END AS movement
FROM running
),
monthly AS (
SELECT
month,
sum(CASE WHEN movement = 'new' THEN mrr_change ELSE 0 END) AS new_mrr,
sum(CASE WHEN movement = 'expansion' THEN mrr_change ELSE 0 END) AS expansion_mrr,
sum(CASE WHEN movement = 'reactivation' THEN mrr_change ELSE 0 END) AS reactivation_mrr,
sum(CASE WHEN movement = 'contraction' THEN mrr_change ELSE 0 END) AS contraction_mrr,
sum(CASE WHEN movement = 'churn' THEN mrr_change ELSE 0 END) AS churned_mrr,
count_if(movement IN ('new', 'reactivation')) AS customers_gained,
count_if(movement = 'churn') AS customers_churned,
sum(mrr_change) AS net_change
FROM classified
GROUP BY 1
)
SELECT
month,
new_mrr / 100.0 AS new_mrr,
expansion_mrr / 100.0 AS expansion_mrr,
reactivation_mrr / 100.0 AS reactivation_mrr,
contraction_mrr / 100.0 AS contraction_mrr,
churned_mrr / 100.0 AS churned_mrr,
sum(net_change) OVER (ORDER BY month) / 100.0 AS ending_mrr
FROM monthly
ORDER BY month DESC
How it works: events collapses all of a customer's item changes at the same moment into one change. running keeps each customer's MRR after every change, so the MRR before it is mrr_after - mrr_change. A customer going from zero to positive is new the first time and a reactivation after that; a customer going from positive to zero has churned; everything else is expansion or contraction. Contraction and churn come out negative.
If you bill in several currencies, the result above is partial. Stripe's full example query converts every currency into your default one with the exchange_rates_from_usd table and adds an FX adjustment line. Start from it rather than extending this one.
Query 2: customer churn rate and gross MRR churn
Keep the events, running, classified and monthly blocks of query 1 and replace its final SELECT with this:
, with_totals AS (
SELECT
*,
sum(customers_gained - customers_churned) OVER (ORDER BY month) AS ending_customers,
sum(net_change) OVER (ORDER BY month) AS ending_mrr
FROM monthly
)
SELECT
month,
lag(ending_customers) OVER (ORDER BY month) AS starting_customers,
customers_churned,
round(100.0 * customers_churned
/ nullif(lag(ending_customers) OVER (ORDER BY month), 0), 2) AS customer_churn_pct,
round(-100.0 * (churned_mrr + contraction_mrr)
/ nullif(lag(ending_mrr) OVER (ORDER BY month), 0), 2) AS gross_mrr_churn_pct
FROM with_totals
ORDER BY month DESC
The denominator is customers (or MRR) at the start of the month, the convention explained in our SaaS churn rate article. Stripe's Billing overview computes its subscriber churn rate with a different denominator, so the two will not match exactly; that article shows by how much on an example. Gross MRR churn counts churn and contraction together, the same numerator as Stripe's "churned revenue" metric in its Billing analytics docs.
Query 3: MRR by product
Summing every change ever recorded for an item gives its current MRR. Grouped by product, it shows where recurring revenue actually sits:
SELECT
p.name AS product,
count(DISTINCT e.customer_id) AS customers_with_changes,
sum(e.mrr_change) / 100.0 AS current_mrr
FROM subscription_item_change_events e
JOIN products p ON p.id = e.product_id
WHERE e.currency = 'usd'
GROUP BY 1
HAVING sum(e.mrr_change) <> 0
ORDER BY 3 DESC
customers_with_changes counts every customer who ever had that product, including those who left, so read it as reach rather than active customers. Add AND e.local_event_timestamp < DATE '2026-10-01' to read MRR by product at the end of September, and compare two dates to see which product is shrinking.
Query 4: customers who churned in the last 30 days
The most actionable query of the four, because it ends with names. Keep the events, running and classified blocks of query 1, then:
SELECT
c.email,
cl.customer_id,
cl.local_event_timestamp AS churned_at,
-cl.mrr_change / 100.0 AS lost_mrr
FROM classified cl
JOIN customers c ON c.id = cl.customer_id
WHERE cl.movement = 'churn'
AND cl.local_event_timestamp >= current_date - INTERVAL '30' DAY
ORDER BY lost_mrr DESC
Sorted by lost MRR, the top of the list is where a call to ask why is worth the most. Schedule it weekly by email and the list arrives on Monday morning.
When you do not need Sigma
Stripe's Billing overview already charts MRR, its movements and churn, and its "Customer MRR changes" report lists every new subscriber, upgrade, downgrade, reactivation and churn as a download. Below a few hundred customers, that export and a spreadsheet answer queries 1, 2 and 4. Our MRR article covers what Stripe puts in its number and how to read the dashboard.
Sigma earns its fee in three cases: you ask the same custom question every month and want it delivered rather than rebuilt; you need a cut the dashboard does not offer, such as churn by product or by price; or you want the raw event log to rebuild metrics with your own conventions.
Sigma also has a ceiling. It only sees Stripe. Whether churned customers ever activated, which channel they came from, what they did in the product the week before they left: that lives in your product analytics, and joining the two needs a warehouse. Stripe's pricing page notes that Stripe Data Pipeline, which sends Stripe data to a warehouse, includes Sigma.
Reading the result as a priority
Query 1 tells you which line of MRR moves most, and query 2 turns it into a rate you can compare month to month. If churned and contraction MRR together exceed new MRR, the Retention stage of your AARRR funnel is the priority, and query 4 gives you this week's first action: call the five largest churned accounts. If churn is small and new MRR is flat, the gap is upstream, in activation or conversion to paid, and Sigma will not show it. Price each gap in monthly dollars, pick the biggest, and work on that one for the week.
Frequently asked questions
What is Stripe Sigma?
Stripe Sigma is an SQL editor inside the Stripe Dashboard that queries your own Stripe data: payments, subscriptions, customers, invoices and payouts. The data is read-only, queries are written in standard ANSI SQL, and results can be downloaded as CSV or scheduled daily, weekly or monthly by email or webhook.
How much does Stripe Sigma cost?
Sigma is a paid add-on billed on the number of successful charges your account processes each month, with a monthly or a cheaper annual plan and overage fees per additional charge. New users get a 30-day free trial, and Sigma is free without limit in test environments. Prices vary by country, so check Stripe's Sigma pricing page for yours.
Which Sigma table should I use for MRR?
Use subscription_item_change_events. Each row is a change to a subscription item that moved MRR or quantity, with the MRR impact in the currency's minor unit (cents for USD). Summing mrr_change over time gives MRR, and classifying each customer's changes gives new, expansion, contraction, churn and reactivation. A v2_beta version adds trial events and fresher data.
Is Stripe Sigma worth it for a small SaaS?
Below a few hundred customers, usually not. Stripe's Billing overview already shows MRR, churn and their movements, and its Customer MRR changes export answers most questions in a spreadsheet. Sigma pays off when you ask the same custom question every month, such as churned MRR by product or a list of churned customers to call.
Sources
- Stripe docs, How Sigma works: https://docs.stripe.com/stripe-data/how-sigma-works
- Stripe docs, Write queries (Sigma query editor, limits, assistant): https://docs.stripe.com/stripe-data/write-queries
- Stripe docs, Query billing data (subscription_item_change_events and the MRR example query): https://docs.stripe.com/stripe-data/query-billing-data
- Stripe docs, Schedule queries: https://docs.stripe.com/data/schedule-queries
- Stripe, Sigma pricing: https://stripe.com/sigma/pricing
- Stripe docs, Billing analytics: https://docs.stripe.com/billing/subscriptions/analytics