CS FundamentalsHardProduct-company placement

What does this query return? SELECT CASE NULL WHEN NULL THEN 'eq' ELSE 'ne' END, CASE WHEN NULL IS NULL THEN 'eq' ELSE 'ne' END;

  1. A. 'eq', 'eq'
  2. B. 'ne', 'eq'
  3. C. 'ne', 'ne'
  4. D. NULL, 'eq'

Correct answer: B. 'ne', 'eq'

A simple CASE compares with =, and NULL = NULL is UNKNOWN, so the ELSE branch gives 'ne'. The searched CASE uses IS NULL, which is TRUE, so it gives 'eq'. A CASE with an ELSE never returns NULL just because nothing matched.

More DBMS and SQL questions

Exams that ask this topic