Why does = NULL return no rows in Databricks SQL?

datachamp
Visitor

Hi everyone,

I have orders with a missing shipped_at value, but this query returns no rows:

SELECT *
FROM orders
WHERE shipped_at = NULL;

What is the correct way to find orders that have no shipping timestamp?

tajamulkhan
Honored Contributor

Use IS NULL. Comparing a value to NULL with = produces an unknown result, and WHERE only keeps rows where the condition is true.

SELECT *
FROM orders
WHERE shipped_at IS NULL;

View solution in original post