Some values cannot be true: a birth date after the day the extract was pulled, a discharge before the admission, a code the system does not allow. Others are only missing. Check each column against what it may hold:
SELECT row_id, mrn, birth_date
FROM hd_registrations_raw
WHERE CAST(birth_date AS DATE) > DATE '2026-07-01';
- A date stored as text compares as text. Dates written year first (2026-07-01) happen to sort correctly; anything in another format does not. Casting to DATE is safer.
- NULL fails every comparison.
length(zip) <> 5 is not true for a missing ZIP, so test zip IS NULL as well.
- Negations with OR:
sex <> 'F' OR sex <> 'M' is true for every row. Use sex NOT IN ('F', 'M').
- Unusual is not impossible. A same-day stay (0 days) or a patient aged 96 is valid.
Missing ZIPs need their own test: NULL fails every comparison.