7. NULL Values: Missing Data Done Right
7.2 How to Find Missing Values with IS NULL and IS NOT NULL
Why. You must find missing rows before you fix or report them.
What. Use IS NULL and IS NOT NULL — special tests for missing.
How. WHERE note IS NULL / WHERE note IS NOT NULL
Steps
- Count rows with missing notes.
- List rows that have a note.
- Same idea on interview_mini tickets.priority.
Examples
Example 1 · dataset: raja_coffee
SELECT COUNT(*) AS missing_notes
FROM orders
WHERE note IS NULL;Output
| missing_notes |
|---|
| 22 |
Meaning. How many orders have no note.
Example 2 · dataset: interview_mini
SELECT ticket_id, agent, priority
FROM tickets
WHERE priority IS NULL;Output
| ticket_id | agent | priority |
|---|---|---|
| 6 | James |
Meaning. Tickets with unknown priority.
Ravindra Bagale's Tip
IS NULL reads like English — keep using it; do not invent = NULL.
Ravindra Bagale's Tip – मराठी
IS NULL इंग्रजीसारखे वाचते — तेच वापरा; = NULL शोधू नका.
Ravindra Bagale's Tip – हिंदी
IS NULL अंग्रेज़ी जैसा पढ़ता है — वही लिखें; = NULL न बनाएँ।