cancel
Showing results forย 
Search instead forย 
Did you mean:ย 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

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?

1 ACCEPTED SOLUTION

Accepted Solutions

tajamulkhan
Valued Contributor III

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

1 REPLY 1

tajamulkhan
Valued Contributor III

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;