Table Emp(id, dept, salary) has rows (1,’HR’,3000), (2,’IT’,5000), (3,’IT’,4000), (4,’HR’,NULL), (5,’Ops’,2000). SELECT AVG(salary) FROM Emp WHERE dept = ‘HR’; What value is returned?
Correct answer D. 3000
Explanation
The WHERE clause keeps two HR rows, salaries 3000 and NULL. AVG ignores NULL inputs, so it averages only the single non-null value and returns 3000. Answering 1500 assumes the NULL is treated as zero and divided over two rows. If you want NULL counted as zero, write AVG(COALESCE(salary, 0)) explicitly.
Answer checked How we write and check questions
Discussion