Learn SQL/Intermediate/NULL Handling/Understanding SQL NULL

Understanding SQL NULL

NULL means 'unknown' or 'missing' — not zero, not an empty string, and genuinely not equal to anything, including another NULL.

What & Why

NULL represents an absent or unknown value. A missing product.feedback.nps_score does not mean a score of zero or an empty string; it means no NPS score was submitted for that feedback row.

NULL is not equal to anything, including another NULL. NULL = NULL evaluates to UNKNOWN, which is why SQL provides IS NULL and IS NOT NULL for missing-value tests.

See How It Works

BUSINESS QUESTION

Product wants to compare = NULL with IS NULL against the real nullable nps_score column.

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 SQL distinguish comparison from IS NULLStep 1 of 4
nps_score = NULL
idnps_scoreexpressionresult
2NULLNULL = NULLUNKNOWN

Ordinary equality with NULL is UNKNOWN—even when the stored NPS score is NULL.

EXAMPLE QUERY
SELECT
  id,
  nps_score,
  nps_score = NULL AS equals_null,
  nps_score IS NULL AS is_null
FROM product.feedback
ORDER BY id;
Now You Try

Practice this concept

Product compares = NULL with IS NULL against the real nullable nps_score column.

Available schema
product

Prefix tables with product.table_name.

idnps_scoreequals_nullis_null
product.feedback
ColumnType
idinteger
user_idinteger
feature_idinteger
ratinginteger
nps_scoreinteger
commenttext
created_attimestamp with time zone
moderation_buckettext
query.sql
Intermediate business practice

Sign up free to try it on a real business scenario