Customer churn rate is one division: customers you lost during a period, divided by customers you had at the start of it. It takes ten seconds to write on a whiteboard.

Getting the same number out of a Stripe subscriptions table takes longer. The table has no "customer left on this date" column. It has statuses, and a few of them look like churn without being churn. If your query groups canceled subscriptions by canceled_at, it is probably counting some customers in the wrong month and some who never left.

Below is a PostgreSQL query that handles those cases, plus a small dataset you can run it against.

The formula and its two assumptions

monthly churn rate = customers lost during the month / paying customers on day 1 of the month * 100 

Two assumptions hide in that line:

  1. The denominator is fixed on day 1. Someone who signs up on the 12th is not part of this month's base, so they can't churn from it either. Leaving them out of both sides keeps the rate honest.
  2. It counts customers, not subscriptions. A customer who drops one of two plans is still a customer.

This post sticks to customer churn. Revenue churn, cohort churn and the monthly vs annual conversion each change the formula a bit, and there's a longer walkthrough of the churn rate formulas if you need those too. Here the focus is on getting clean inputs out of the data.

Trap 1: canceled_at is not the day the customer left

Most SaaS products let users cancel "at the end of the billing period". In Stripe that sets cancel_at_period_end, and the customer keeps paid access until the period runs out.

The timestamp you're tempted to use doesn't reflect that. The Stripe Subscription object reference says that for these cancellations canceled_at holds the time of the cancellation request, not the end of the period. A customer who clicks "cancel" on September 20 and is billed through October 15 shows up as September churn if you group by canceled_at.

Use ended_at. It is the moment the subscription actually ended.

Trap 2: past_due is not churn yet, unpaid is

When a renewal payment fails, the subscription moves to past_due and Stripe retries the charge. What happens after the retries depends on your billing settings: the subscription can end up canceled, unpaid, or stay past_due.

So:

  • past_due is a customer you might still keep. Counting them as churned inflates the number, and some of them come back as soon as a retry goes through.
  • unpaid is a customer who stopped paying. Stripe's subscription status table tells you to revoke access on canceled or unpaid, which is a decent definition of "churned".

The catch with unpaid is that the subscription hasn't ended, so ended_at stays empty, and the object has no "became unpaid at" timestamp. You have to record it yourself. When your webhook handler receives customer.subscription.updated and the status changes to unpaid, write the event time into an unpaid_since column. Clear it if the customer pays and the status returns to active.

Trap 3: some subscriptions were never customers

These statuses should never reach your denominator:

  • incomplete and incomplete_expired: the first payment failed. If nobody pays within 23 hours the subscription expires. These are failed signups, not lost customers.
  • trialing: not paying yet. Count a trial user from trial_end, the moment they convert.
  • paused after a trial: a trial can end without a payment method and pause instead of converting. That user never paid, so they never churned. Record paused_since the same way as unpaid_since.

Trap 4: subscriptions are not customers

Group by customer_id, not by subscription. Two cases break subscription-level counts:

  • A customer has two subscriptions and cancels one. They're still paying you.
  • A customer cancels on the 20th and resubscribes on the 28th. Whether that counts as churn is a policy choice. The query below checks who is paying on day 1 of the next month, so this customer is not counted as churned. If your team wants to see every cancellation, track reactivations as a separate metric instead of changing the churn definition.

The table

This assumes you mirror Stripe subscriptions into your own database, with the two extra columns from your webhook handler:

CREATE TABLE subscriptions ( id text PRIMARY KEY, customer_id text NOT NULL, status text NOT NULL, -- Stripe subscription.status start_date timestamptz NOT NULL, trial_end timestamptz, canceled_at timestamptz, -- when cancellation was requested ended_at timestamptz, -- when the subscription actually ended cancel_reason text, -- cancellation_details.reason unpaid_since timestamptz, -- set by your webhook handler paused_since timestamptz -- set by your webhook handler ); 

The query

First, turn every subscription into a paid span: when it started paying and when it stopped.

CREATE OR REPLACE VIEW paid_spans AS SELECT customer_id, COALESCE(trial_end, start_date) AS paid_from, COALESCE(LEAST(ended_at, unpaid_since, paused_since), 'infinity') AS paid_until, CASE WHEN unpaid_since IS NOT NULL OR cancel_reason IN ('payment_failed', 'payment_disputed') THEN 'involuntary' ELSE 'voluntary' END AS churn_type FROM subscriptions WHERE status NOT IN ('incomplete', 'incomplete_expired'); 

LEAST does useful work here. In PostgreSQL it ignores NULL arguments, so it returns the earliest of whichever stop dates exist. (MySQL returns NULL if any argument is NULL, so port this line carefully.) A trial that paused at trial_end gets paid_from = paid_until, a zero-length span that never matches a month boundary.

Then compare who was paying on day 1 of each month with who is paying on day 1 of the next:

WITH months AS ( SELECT m::timestamptz AS month_start, (m + interval '1 month')::timestamptz AS month_end FROM generate_series(timestamp '2026-09-01', timestamp '2026-10-01', interval '1 month') AS m ), at_start AS ( -- paying customers on day 1 of the month SELECT DISTINCT mo.month_start, mo.month_end, s.customer_id FROM months mo JOIN paid_spans s ON s.paid_from <= mo.month_start AND s.paid_until > mo.month_start ), at_end AS ( -- paying customers on day 1 of the next month SELECT DISTINCT mo.month_start, s.customer_id FROM months mo JOIN paid_spans s ON s.paid_from <= mo.month_end AND s.paid_until > mo.month_end ), churned AS ( -- paying at start, not paying at end SELECT a.month_start, a.month_end, a.customer_id FROM at_start a LEFT JOIN at_end e USING (month_start, customer_id) WHERE e.customer_id IS NULL ), churn_typed AS ( -- label each churned customer by the span that ended last SELECT DISTINCT ON (c.month_start, c.customer_id) c.month_start, c.customer_id, s.churn_type FROM churned c JOIN paid_spans s ON s.customer_id = c.customer_id AND s.paid_until > c.month_start AND s.paid_until <= c.month_end ORDER BY c.month_start, c.customer_id, s.paid_until DESC ) SELECT to_char(a.month_start, 'YYYY-MM') AS month, count(DISTINCT a.customer_id) AS customers_at_start, count(DISTINCT t.customer_id) AS churned, count(DISTINCT t.customer_id) FILTER (WHERE t.churn_type = 'voluntary') AS voluntary, count(DISTINCT t.customer_id) FILTER (WHERE t.churn_type = 'involuntary') AS involuntary, round(100.0 * count(DISTINCT t.customer_id) / count(DISTINCT a.customer_id), 2) AS churn_rate_pct FROM at_start a LEFT JOIN churn_typed t USING (month_start, customer_id) GROUP BY a.month_start ORDER BY a.month_start; 

The month list comes from generate_series with a timestamp and an interval step. Replace the hardcoded dates with your own range, and stop at the last complete month, because the current one will always look artificially good.

Testing it on edge cases

Here is a dataset with one customer per trap:

Test data (11 customers)
INSERT INTO subscriptions VALUES -- c1: plain active customer ('s1','c1','active','2026-01-10',NULL,NULL,NULL,NULL,NULL,NULL), -- c2: canceled Sep 20 at period end, paid through Oct 15 ('s2','c2','canceled','2026-03-15',NULL,'2026-09-20','2026-10-15','cancellation_requested',NULL,NULL), -- c3: payment failed, still in retries ('s3','c3','past_due','2026-02-01',NULL,NULL,NULL,NULL,NULL,NULL), -- c4: retries exhausted, unpaid since Oct 10 ('s4','c4','unpaid','2026-04-03',NULL,NULL,NULL,NULL,'2026-10-10',NULL), -- c5: first payment never succeeded ('s5','c5','incomplete_expired','2026-09-05',NULL,NULL,'2026-09-06',NULL,NULL,NULL), -- c6: trial ended without a card, paused ('s6','c6','paused','2026-09-25','2026-10-09',NULL,NULL,NULL,NULL,'2026-10-09'), -- c7: dropped one of two subscriptions ('s7a','c7','canceled','2026-02-11',NULL,'2026-10-05','2026-10-05','cancellation_requested',NULL,NULL), ('s7b','c7','active','2026-03-01',NULL,NULL,NULL,NULL,NULL,NULL), -- c8: new signup mid-October ('s8','c8','active','2026-10-12',NULL,NULL,NULL,NULL,NULL,NULL), -- c9: canceled Oct 20, came back Oct 28 ('s9a','c9','canceled','2026-05-02',NULL,'2026-10-20','2026-10-20','cancellation_requested',NULL,NULL), ('s9b','c9','active','2026-10-28',NULL,NULL,NULL,NULL,NULL,NULL), -- c10: canceled immediately in September ('s10','c10','canceled','2026-06-07',NULL,'2026-09-10','2026-09-10','cancellation_requested',NULL,NULL), -- c11: canceled by Stripe after failed payments ('s11','c11','canceled','2026-07-19',NULL,'2026-10-25','2026-10-25','payment_failed',NULL,NULL); 

Result on PostgreSQL 16:

 month | customers_at_start | churned | voluntary | involuntary | churn_rate_pct ---------+--------------------+---------+-----------+-------------+---------------- 2026-09 | 8 | 1 | 1 | 0 | 12.50 2026-10 | 7 | 3 | 1 | 2 | 42.86 

October churn is c2 (left at period end), c4 (unpaid) and c11 (canceled after failed payments). The past-due customer, the trial that never converted, the customer with a second plan, the returning customer and the new signup all stay out, which is what we want.

Compare the naive version, counting canceled subscriptions by date_trunc('month', canceled_at). It also returns 3 for October, but they're the wrong 3: c7 and c9, who are still paying, plus c11. It puts c2 in September, a month early, and misses c4 completely because an unpaid subscription isn't canceled. Same total, wrong customers, so any follow-up analysis on "who churned" goes in the wrong direction.

Why split voluntary and involuntary

The two columns at the end aren't decoration. A customer who chose to leave and a customer whose card expired need completely different fixes: product and onboarding work for the first, dunning and card updaters for the second. Recurly's churn rate benchmarks report the two separately for the same reason. If your total churn moves, the split tells you which team should look at it. It also decides what any retention automation sends next: a churn-prevention workflow, like the ones Bigstream sets up for SaaS teams, needs to know whether the right message is "here's what you're missing" or "your card was declined"

Stripe gives you most of the signal in cancellation_details.reason: payment_failed and payment_disputed mean Stripe canceled the subscription automatically, cancellation_requested means a person did it through the API or the Dashboard. unpaid subscriptions are involuntary by definition.

Monthly to annual: don't multiply by 12

If you need an annual figure, compound it:

annual churn = 1 - (1 - monthly churn)^12 

At 2% monthly that's about 21.5%, not 24%. Multiplying by 12 slightly overstates small rates and gets badly wrong at larger ones.

Decisions the query can't make for you

A few choices depend on your business, and it helps to write them down next to the query:

  • Grace period. How long can a customer stay past_due before you call it churn, even if Stripe hasn't moved them to unpaid?
  • Reactivations. Is a cancel-and-return inside the same month churn or not? Pick one and keep it.
  • Paused customers. If you let paying customers pause, decide whether a pause is churn. This query treats it as a stop.
  • Status history. This model stores the current state. If customers move between unpaid and active often, keep a separate table of status changes from your webhooks and build paid_spans from that instead.

Once these rules exist in SQL instead of in someone's head, the churn number stops changing depending on who ran the query.