Question 1
The `EMPLOYEES` table contains this row: ``` EMP_ID FIRST_NAME LAST_NAME SALARY COMMISSION ------ ---------- --------- ------ ---------- 103 Dave Novak 4800 (null) ``` What value does the following query return? ```sql SELECT commission * 0 + salary AS "Adjusted Pay" FROM employees WHERE emp_id = 103 ```
A. NULLCorrect answer
COMMISSION is null for this row, so COMMISSION * 0 is null, and null + SALARY is null as well — if any operand of an arithmetic operator is null, the result is null. The query returns one row whose single column is null.
B. 4800
Assumes that multiplying by zero forces the null to 0, leaving 0 + 4800. Zero is not special: null times any number is still null, and adding salary to a null operand keeps the result null.
C. 0
Assumes Oracle substitutes zero for a null number in arithmetic, so the whole expression collapses to zero. Oracle performs no such substitution; obtaining a number requires an explicit NVL or COALESCE around the null operand.
D. The statement fails with ORA-00932: inconsistent datatypes
Assumes a null column value is untyped and therefore cannot take part in arithmetic. Null is a legal value of the NUMBER column COMMISSION, so the expression is type-correct and executes — it simply evaluates to null.
Explanation
Null in Oracle means the value is unavailable, not zero, and it propagates through every arithmetic operator: if any operand of +, -, *, or / is null, the entire expression evaluates to null. Multiplying by zero is no exception, because the multiplication cannot be resolved without knowing the unknown operand, and the surrounding addition then inherits that null. Only an explicit conversion such as NVL(commission, 0) turns the missing value into a number that arithmetic can consume.