Solve “Coalesce null salaries to zero”

Free. Runs in your browser, no install.

SQL · NULL Handling & Data Types

What happens when NULL is added to a number?

Easynullarithmetic

Interview question

What happens when NULL is added to a number?

How to answer

The short answer

Usually:

SQL
10 + NULL

produces:

Output
NULL

because the result is unknown.

Similarly, string concatenation involving NULL is dialect-dependent. Some systems propagate NULL, while others/functions may treat it differently.

For portable logic, explicitly handle it:

SQL
COALESCE(name, '')

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