Practice mode DBMS and SQL

Table Emp(id, bonus) has rows (1,500), (2,NULL), (3,NULL), (4,200). SELECT COUNT(*) FROM Emp WHERE bonus = NULL; What is the result?

Correct answer B. 0

Explanation

Comparing anything with NULL using = gives UNKNOWN, never TRUE, even when the stored value is itself NULL. WHERE keeps only rows where the condition is TRUE, so no row qualifies and the count is 0. The query is valid, so no error is raised. To find missing bonuses, write WHERE bonus IS NULL, which would return 2.

Report a problem

Answer checked How we write and check questions

Tip: press A, B, C or D to answer, and N for the next question.

Advertisement

Have a question about this answer?

Your email address will not be published. Required fields are marked *

Links and website addresses are not allowed in comments.