Compute per-column fill rate
COUNT(column) skips NULLs, so dividing it by COUNT(*) yields the fill rate of each column in a single pass.
The task
Before building a dashboard on customers you want to know, per field, what share of rows actually has a value. One query answers it for every column at once.
The snippet
Runs unchanged on current versions of SQL Server, PostgreSQL, MySQL, SQLite and Oracle.
SELECT
ROUND(100.0 * COUNT(name) / COUNT(*), 1) AS name_filled_pct,
ROUND(100.0 * COUNT(email) / COUNT(*), 1) AS email_filled_pct,
ROUND(100.0 * COUNT(phone) / COUNT(*), 1) AS phone_filled_pct
FROM customers;
Cómo funciona
COUNT(name) counts only rows where name is not NULL while COUNT(*) counts everything, so the ratio is exactly the fill rate; multiplying by 100.0 keeps the decimals. One expression per column produces a compact one-row scorecard. Note this counts only NULL; empty strings still 'fill', which the blank-strings recipe handles.
Variations
One row per column (easier to read wide tables)
SELECT 'name' AS column_name,
ROUND(100.0 * COUNT(name) / COUNT(*), 1) AS filled_pct
FROM customers
UNION ALL
SELECT 'email', ROUND(100.0 * COUNT(email) / COUNT(*), 1)
FROM customers
UNION ALL
SELECT 'phone', ROUND(100.0 * COUNT(phone) / COUNT(*), 1)
FROM customers;
Last 90 days only (PostgreSQL, Oracle date arithmetic)
PostgreSQL OracleSELECT ROUND(100.0 * COUNT(phone) / COUNT(*), 1) AS phone_filled_pct
FROM customers
WHERE created_at >= CURRENT_DATE - 90;
Questions that come up
Fill rate is 100 percent. Is the column trustworthy?
Only in the NULL sense. Empty strings, whitespace, zero and placeholder values like 'n/a' all count as filled, so a perfect fill rate can hide a column nobody really populates. Follow up with the blank-strings check on any column that matters before you build on it.
Keep reading
Run these with autocomplete that knows your tables
SQLly is a native SQL workbench for macOS, Windows and Linux. Paste a snippet into a live connection and you get schema-aware IntelliSense, a plan viewer and guards against unsafe edits.