CS FundamentalsHardGATE CS · Amazon/Microsoft SDE MCQ

Table Bill(id, cust, region, amt) rows: (1, 'Kavi', 'E', 300), (2, 'Lata', 'W', NULL), (3, 'Kavi', 'E', 450), (4, 'Mona', 'W', 300), (5, 'Nair', NULL, 200), (6, 'Lata', 'W', 450), (7, 'Mona', 'E', NULL). What does this query return? SELECT COUNT(*) FROM Bill WHERE region NOT IN (SELECT region FROM Bill WHERE amt > 400);

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

Correct answer: D. 0

The subquery yields {'E', 'W'} (no NULL), so every E or W row is excluded. Nair's region is NULL, and NULL NOT IN (...) is UNKNOWN, not TRUE, so that row is dropped too: 0.

More DBMS and SQL questions

Exams that ask this topic