The Trouble with Null

Talk it through out loud with your AI coach.

The problem

  • medium
  • Pro

A query for users whose referral code is not equal to a particular value unexpectedly leaves out users with no referral code at all. Explain how null behaves in comparisons and how you'd fix the query.

What a strong answer covers

  • What a missing value means in SQL and how comparisons treat it.
  • Which comparison outcomes a filter keeps and which it drops.
  • The dedicated way to test for missing values, and how to fold it into the condition.
  • At least one other place where missing values cause surprising results.

Common mistake: Expecting not equal to behave like ordinary logic, so rows with no value silently vanish from the result.

Knowing this is half of it. Saying it clearly out loud is the part the coach helps you practise.

Practise it out loud