How to calculate Defect Rate

Defect rate is the percentage of produced or inspected units that fail quality standards.

Formula

Defect rate = defective units ÷ units inspected × 100

SQL query

This example assumes: inspections(batch_id, product_id, inspected_at, units_inspected, units_defective). It is written in PostgreSQL syntax; date functions differ slightly in MySQL, BigQuery and SQLite, and your column names will differ from these.

SELECT product_id,
       SUM(units_defective) * 100.0 / NULLIF(SUM(units_inspected), 0) AS defect_pct
FROM inspections
WHERE inspected_at >= DATE '2026-07-01'
GROUP BY product_id
ORDER BY defect_pct DESC;

Common mistakes that make Defect Rate wrong

  • Sampled inspection rates are estimates; do not present them as exact.
  • Rework that passes on a second inspection still counts as a first-time failure for yield measures.
  • Defects per million is more appropriate when rates are very low.

Ask for Defect 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.

  • Which products have the highest defect rate this quarter?
  • How did defect rate change after the supplier change?

Frequently asked questions

What is Defect Rate?
Defect rate is the percentage of produced or inspected units that fail quality standards.
How do you calculate Defect Rate?
Defect rate = defective units ÷ units inspected × 100. The SQL example on this page shows the same calculation against a simple table.
What commonly goes wrong when calculating Defect Rate?
Sampled inspection rates are estimates; do not present them as exact.