How to calculate Customer Retention Rate

Customer retention rate is the percentage of customers you keep over a period.

Formula

Retention rate = customers from the starting group who bought again in the later window ÷ customers in the starting group × 100

SQL query

This example assumes: orders(customer_id, ordered_at). It is written in PostgreSQL syntax; date functions differ slightly in MySQL, BigQuery and SQLite, and your column names will differ from these.

WITH start_set AS (
  SELECT DISTINCT customer_id FROM orders
  WHERE ordered_at >= DATE '2025-10-01' AND ordered_at < DATE '2026-01-01'
), kept AS (
  SELECT DISTINCT o.customer_id FROM orders o
  JOIN start_set USING (customer_id)
  WHERE o.ordered_at >= DATE '2026-07-01' AND o.ordered_at < DATE '2026-10-01'
)
SELECT (SELECT COUNT(*) FROM kept) * 100.0
     / NULLIF((SELECT COUNT(*) FROM start_set), 0) AS retention_pct;

Common mistakes that make Customer Retention Rate wrong

  • For retail, 'active' needs a definition, such as bought in the last 12 months; otherwise nobody ever churns.
  • New customers must be excluded from the numerator.
  • Seasonal shoppers look lost in off-season windows.

Ask for Customer Retention Rate in plain English

Instead of writing the query yourself, you can type the question. SchemaChat turns it into SQL against your connected database or uploaded file, runs it, and shows the SQL and the figures it used so you can check the answer before you share it. It does not replace your judgement about the definition: check that the query matches the formula your business uses.

  • What share of last year's customers bought again this year?
  • How does retention differ by acquisition channel?

Frequently asked questions

What is Customer Retention Rate?
Customer retention rate is the percentage of customers you keep over a period.
How do you calculate Customer Retention Rate?
Retention rate = customers from the starting group who bought again in the later window ÷ customers in the starting group × 100. The SQL example on this page shows the same calculation against a simple table.
What commonly goes wrong when calculating Customer Retention Rate?
For retail, 'active' needs a definition, such as bought in the last 12 months; otherwise nobody ever churns.