Unit 03.04: Reporting the denominator you actually measured
Unit ID: SQL-M03-U05 - Estimated active time: 12-15 minutes Objective: produce a figure a reviewer can trust by publishing its coverage alongside it.
One number is never enough
Three true statements about the same column:
SELECT
COUNT(*) AS responses, -- 500
COUNT(rating) AS rated, -- 440
ROUND(AVG(rating), 2) AS avg_rating, -- 3.05
ROUND(100.0*COUNT(rating)/COUNT(*), 1) AS coverage_pct -- 88.0
FROM feedback;
Publishing only avg_rating invites the reader to assume coverage is 100%. Publishing all four takes the same amount of space and removes the ambiguity entirely.
A reusable completeness check
Run this on any column before you report a statistic about it:
SELECT
'country' AS column_name,
COUNT(*) AS rows,
COUNT(country) AS present,
COUNT(*) - COUNT(country) AS missing,
ROUND(100.0*COUNT(country)/COUNT(*), 1) AS pct_present
FROM customers;
-- country | 4812 | 4512 | 300 | 93.8
93.8% coverage is worth knowing before you split customers by region. It is also the sentence that protects you when someone later asks why the segments do not sum to the headline total.
Worked example - the full honest statement
SELECT
COUNT(*) AS completed_orders,
SUM(order_total) AS revenue,
ROUND(AVG(order_total), 2) AS avg_order_value
FROM orders
WHERE status = 'completed';
-- 988 | 2685905.00 | 2718.53
Reported properly: "June 2026 revenue ₹26,85,905 across 988 completed orders (average ₹2,718.53). Excludes 12 orders still pending. No refunds deducted."
Every clause in that sentence came from a number in the result or a filter in the query. Nothing was estimated.
Practice
Write one query that reports, for the customers table, how many rows have a country, how many do not, and the percentage present - then write the one-sentence caveat you would attach to a regional breakdown.
Check your answer
SELECT
COUNT(*) AS customers,
COUNT(country) AS with_country,
COUNT(*) - COUNT(country) AS without_country,
ROUND(100.0*COUNT(country)/COUNT(*), 1) AS pct_present
FROM customers;
-- 4812 | 4512 | 300 | 93.8
Caveat: "Regional figures cover 4,512 of 4,812 customers (93.8%); 300 have no recorded country and are excluded from the split."
Takeaway
A statistic without its denominator is an invitation to misread it. Publish the coverage in the same result and the caveat writes itself.
---
