Tricky NULL Questions

This SQL quiz is all about NULL, the value that means "unknown" and breaks many people's intuition. You will predict how comparisons, NOT IN, aggregates, grouping and sorting treat NULL, and where SQLite, MySQL and PostgreSQL differ.

Hard 10 questions ~8 minutes Pass at 80% SQLite

Choose a mode

Playing as a guest: sign in to keep your XP and streak.

Sample question

Question 1 of 10

What does this print?

SELECT CASE WHEN NULL = NULL THEN 'equal' ELSE 'not equal' END;
Show the answer

B. not equal Comparing anything with NULL gives NULL (unknown), not true, so CASE falls through to ELSE. Use IS NULL, or IS NOT DISTINCT FROM in PostgreSQL (<=> in MySQL, IS in SQLite) to compare values that may be NULL.

What this quiz covers

  • Why NULL = NULL is not true
  • NOT IN vs NOT EXISTS when the list contains NULL
  • Aggregates and COUNT with NULL values
  • Three-valued logic with AND and OR
  • Sorting and grouping NULL, and NULLIF / COALESCE

Questions people ask

Do I need an account?

No. Anyone can play. Sign in to keep your XP, streak, badges and history.

Can I retake it?

Yes. Your best score is kept, and the questions and answers are shuffled each time.