Atterna
RUEN
Get access

NULL

The value is unknown or missing. It is not zero and not an empty string, and it is not even equal to itself: NULL = NULL is not true.

FormulaNULL = unknown · x = NULL is never true · use IS NULL

Try it · 30 seconds · from Atterna’s practice

productrating
Wireless headphones4.6
Set of wine glasses4.5
Scented candleNULL
Travel mug4.8
SELECT AVG(rating) FROM catalog;

What does it return?

Preparing the practice…

How we work it through

  1. 1

    Count NULLs in every column you filter or average.

  2. 2

    Filter with IS NULL / IS NOT NULL.

  3. 3

    Decide what NULL means here — no code, unknown, not yet — and handle it on purpose.

On the practice dataset

The query we run on Meridian, Atterna’s practice marketplace, and what it returns.

SELECT COUNT(*) FILTER (WHERE promo_code IS NULL) AS no_code,
       COUNT(promo_code) AS with_code
FROM meridian.orders
WHERE status = 'paid';
-- WHERE promo_code = NULL returns 0 rows

Result6,696 paid orders without a code, 2,375 with one; = NULL finds none

The common trap

Filtering with = NULL (use IS NULL), or letting AVG silently skip NULLs so the average covers fewer rows than you think.

When an AI answers

An AI assistant

“No orders were placed without a promo code.”

What it didn’t know
It filtered with = NULL, which is never true, so the query returned nothing.
Ask back
“Use IS NULL instead of = NULL — how many orders have no code?”
Paste a real AI answer into the checker — it writes these questions for you →

Read next

Examples use Meridian, Atterna’s fictional practice marketplace.