SQL IS NULL

The only correct way to check for a missing value — = NULL never works, no matter how tempting it looks.

What & Why

NULL means "no value recorded" — not zero, not an empty string, genuinely absent. IS NULL is the only way to test for it; ordinary comparisons like = NULL never return true, not even when comparing a NULL to itself.

See How It Works

BUSINESS QUESTION

Find product feedback rows where nps_score is missing.

iduser_idfeature_idratingnps_scorecommentcreated_at
1101159Clear and useful2024-01-25 12:15:00+00
210224NULLExport worked well2024-02-20 15:40:00+00
3103147Helpful setup flow2024-03-18 09:05:00+00
410433NULLNeeds clearer timing2024-04-08 17:30:00+00
Watch is null check each rowRow 1 of 4
-- checking 1: 9 IS NULL?FALSE — dropped
idnps_score
19
2NULL
37
4NULL

nps_score IS NULL is false for 1.

EXAMPLE QUERY
SELECT id, user_id, rating
FROM product.feedback
WHERE nps_score IS NULL;
Now You Try

Practice this concept

Marketing wants leads that have not converted yet.

Available schema
marketing

Prefix tables with marketing.table_name.

idemailconverted_at
marketing.leads
ColumnType
idinteger
campaign_idinteger
emailtext
created_attimestamp with time zone
qualified_attimestamp with time zone
converted_attimestamp with time zone
lead_scoreinteger
sourcetext
countrytext
archive_statustext
query.sql
Beginner business practice

Sign up free to try it on a real business scenario