# Handle SQL NULL semantics correctly in analytical reports Separate missing values from measured zeros: use IS NULL, COUNT(column) and COALESCE deliberately, then reconcile totals against a hand-checked sample. - Canonical: https://satracking.net/guides/sql-null-semantics-reporting/ - Language: en - Category: platforms - Level: intermediate - Published: 2026-11-14 - Updated: 2026-11-23 --- Separate missing values from measured zeros: use IS NULL, COUNT(column) and COALESCE deliberately, then reconcile totals against a hand-checked sample. It focuses on clear definitions, correct analytical scope and checks that make conclusions reproducible. ## Define the analytical question State the decision or question the analysis must support. Specify the population, unit of analysis, time window and metric scope. Identify the source fields and transformations required, and record assumptions that could change the result. Agree the vocabulary with domain owners, keep assumptions separate from confirmed facts, and record which constraints are mandatory rather than preferred. ## Apply a repeatable method Distinguish missing, unknown and not-applicable values; understand comparisons that evaluate to unknown; use IS NULL and IS NOT NULL explicitly; choose COUNT(*) or COUNT(column) intentionally; document when COALESCE changes business meaning. ## Check interpretation and edge cases Replacing every NULL with zero can create false measurements and distort averages, rates and counts. Preserve the difference between absence of a value and a measured zero. Validate the result with a small known example, inspect missing or duplicated records, and compare equivalent periods and populations. Keep the denominator visible, distinguish observed behavior from causal explanation, and test a small hand-checked sample before trusting the result. Record the input version, rule set, execution date and unresolved exceptions. ## Make the analysis reproducible Record the report configuration, query or exploration settings, source freshness and definition version. Share a concise interpretation with limitations and next actions. Assign an accountable owner for definitions, thresholds and exceptions, and define the event that triggers an earlier review. Re-run the same checks after material tracking, schema or business-process changes. ## Review checklist - Is the population, grain and time window explicit? - Are terms, keys, units and time boundaries defined? - Do the selected fields match the intended scope? - Have duplicates, missing values and boundary cases been checked? - Are limitations and assumptions visible? - Is there an owner and a review trigger? - Can another analyst reproduce the result? ## Official references - Comparison Functions and Operators — https://www.postgresql.org/docs/current/functions-comparison.html (verified 2026-11-23) - Aggregate Functions — https://www.postgresql.org/docs/current/functions-aggregate.html (verified 2026-11-23)