Skip to interview prep
Apexed

5. How do NULLs behave in SQL?

MediumSQL

Technical

Type or dictate your answer. Your draft is saved on this device.

Show model answer

NULL means unknown, so comparisons with = or <> return unknown rather than true. Use IS NULL / IS NOT NULL. Aggregates such as SUM and AVG ignore NULLs, while COUNT(*) counts all rows and COUNT(column) skips NULLs.

COALESCE replaces NULLs with a default; be careful, because NOT IN against a list containing NULL returns no rows.

How do NULLs behave in SQL — Data & analytics interview question — Apexed