Table Pay(id, salary, bonus) has one row (1, 5000, NULL). SELECT salary + bonus FROM Pay; What is returned?
Correct answer A. NULL
Explanation
In SQL, an arithmetic expression with a NULL operand yields NULL, because NULL means an unknown value and an unknown added to 5000 is still unknown. The result is not 5000; NULL is not treated as zero in expressions. Aggregates such as SUM skip NULLs, but row-level arithmetic does not. Write salary + COALESCE(bonus, 0) to treat a missing bonus as zero.
Answer checked How we write and check questions
Discussion