How to calculate Net Promoter Score (NPS)
Net Promoter Score measures customer loyalty from one question: how likely are you to recommend us, on a 0 to 10 scale.
Formula
NPS = % promoters (9–10) − % detractors (0–6)SQL query
This example assumes: nps_responses(id, score, responded_at, segment). It is written in PostgreSQL syntax; date functions differ slightly in MySQL, BigQuery and SQLite, and your column names will differ from these.
SELECT segment,
COUNT(*) AS responses,
(COUNT(*) FILTER (WHERE score >= 9) - COUNT(*) FILTER (WHERE score <= 6)) * 100.0
/ NULLIF(COUNT(*), 0) AS nps
FROM nps_responses
WHERE responded_at >= DATE '2026-01-01'
GROUP BY segment
ORDER BY nps DESC;Common mistakes that make Net Promoter Score (NPS) wrong
- Passives (7–8) count in the total but not in either group; leaving them out inflates NPS.
- NPS ranges from −100 to 100; it is not a percentage.
- Small samples swing NPS by tens of points; show the number of responses.
Ask for Net Promoter Score (NPS) 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 is our NPS by customer segment this year?
- How did NPS change after the last release?