SQL Beginner Challenge 13: Filtering NULL Values with IS NULL and IS NOT NULL

Difficulty: Beginner
Estimated time: 10–15 minutes
SQL concepts: NULL, IS NULL, IS NOT NULL, filtering missing data
Goal: Learn how to correctly filter rows based on missing or present values.

The Scenario

After cleaning up missing values with COALESCE, a data analyst asks:

“Can we find only the rows that still have missing values?”

In SQL, NULL behaves differently from regular values.
To filter it correctly, you must use IS NULL or IS NOT NULL.

Database Table

products

column_nametypedescription
product_idINTEGERUnique product ID
nameTEXTProduct name
categoryTEXTProduct category
supplier_notesTEXTOptional notes from supplier (can be NULL)

Sample Data

product_idnamecategorysupplier_notes
101Wireless MouseAccessoriesNULL
102Mechanical KeyboardAccessoriesBest seller
10327-inch MonitorDisplaysNULL
104USB-C HubAccessoriesLimited stock
105Laptop StandWorkspaceNULL

Your Task

Write a SQL query that returns:

  • Product name
  • supplier_notes

…but only for products where supplier_notes is missing.

Expected Output

namesupplier_notes
Wireless MouseNULL
27-inch MonitorNULL
Laptop StandNULL

Constraints

  • Use IS NULL to filter missing values
  • Do not use = NULL
  • Do not use SELECT *

Hint (Optional)

In SQL:

  • = NULL ❌ does not work
  • IS NULL ✅ is the correct way

The same applies to IS NOT NULL.

SELECT
name,
supplier_notes
FROM products
WHERE supplier_notes IS NULL;

Explanation

  • IS NULL checks whether a column has no value.
  • Regular comparison operators (=, !=) do not work with NULL.
  • This pattern is commonly used for:
    • Data quality checks
    • Finding incomplete records
    • Debugging pipelines

Common Mistakes

  1. Using = NULL WHERE supplier_notes = NULL -- ❌ always false
  2. Forgetting NULLs behave differently
  3. Filtering after replacing NULLs with COALESCE
    • You must filter before replacing, or use the raw column.

Try:

  1. Return products that do have supplier notes (IS NOT NULL)
  2. Count how many products are missing notes
  3. Combine IS NULL with LEFT JOIN to find missing relationships

Next Challenge

Beginner Challenge #14: Filtering Ranges with BETWEEN

🔗 View reference solution on GitHub
(After you’ve tried the challenge)

Want more practical SQL challenges?
Subscribe to the Solve With SQL newsletter and get new problems delivered to your inbox.