Solve “Coalesce null salaries to zero”

Free. Runs in your browser, no install.

SQL · NULL Handling & Data Types

What is three-valued logic?

Easythree-valued logicunknownnull

Interview question

What is three-valued logic?

How to answer

The short answer

SQL has:

Output
TRUE
FALSE
UNKNOWN

Because NULL represents an unknown value.

So:

SQL
NULL = NULL

is UNKNOWN.

It is not TRUE because SQL cannot prove two unknown values are equal.

That shows up in filters:

SQL
WHERE column = 10

Rows where column is NULL do not pass, because the comparison is UNKNOWN.

Lock it in with a real drill

You remember an answer longer once you have used it. Try a hands-on problem on this concept.

Open related drill