CS FundamentalsHardProduct placement · SQL round

Table Sale(id, rep, region, amt) rows: (1, 'Ira', 'N', 100), (2, 'Jai', 'S', 250), (3, 'Ira', 'S', NULL), (4, 'Kim', 'N', 300), (5, 'Jai', 'N', 150), (6, 'Ira', 'N', 200), (7, 'Lal', NULL, 120). What does this query return?

Table Sale(id, rep, region, amt) rows: (1, 'Ira', 'N', 100), (2, 'Jai', 'S', 250), (3, 'Ira', 'S', NULL), (4, 'Kim', 'N', 300), (5, 'Jai', 'N', 150), (6, 'Ira', 'N', 200), (7, 'Lal', NULL, 120). What does this query return?
SELECT COUNT(*) FROM Sale
WHERE region NOT IN ('S', NULL);
  1. A. 5
  2. B. 0
  3. C. 6
  4. D. 4

Correct answer: B. 0

region NOT IN ('S', NULL) means region <> 'S' AND region <> NULL; the second comparison is always UNKNOWN, so no row can be TRUE.

More DBMS and SQL questions

Exams that ask this topic