Problems / Sentinel Values Cleanup / Editorial
NULLIF(NULLIF(station, 'N/A'), '')
NULLIF(value, -999)
COALESCE(..., 'unknown')
COUNT(*)
AVG(value)
readings > 0, avg_value NULL
Sentinel values are lies told in-band: -999 is a perfectly valid float to every aggregate that touches it. NULL is SQL's out-of-band "absent" marker, and NULLIF is the purpose-built converter — cleaning is therefore *type-honesty restoration*, done once in a CTE so every downstream aggregate inherits correct semantics for free. The pattern generalizes: find the domain's magic values (-999, 9999-12-31, 'N/A', empty string), NULLIF them at the earliest layer, and let COUNT/AVG/MIN/MAX behave the way their authors intended.
-999
NULLIF
9999-12-31
'N/A'
Solve Sentinel Values Cleanup yourself →