Management & CommerceHardBusiness analyst · SQL test

Table a has key values 1, NULL and 2; table b has key values 1, NULL and 3. How many rows does SELECT * FROM a JOIN b ON a.k = b.k return?

  1. A. 2
  2. B. 1
  3. C. 3
  4. D. 0

Correct answer: B. 1

Only the rows with key 1 match. NULL = NULL is unknown, not true, so the two NULL keys do not join to each other; 2 and 3 have no partners. Joining NULLs requires an explicit condition such as a.k IS NOT DISTINCT FROM b.k.

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic