CS FundamentalsHardGATE CS · SQL

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 NOT (region = 'N');
  1. A. 2
  2. B. 3
  3. C. 4
  4. D. 7

Correct answer: A. 2

Only rows where region = 'N' is FALSE survive: the two 'S' rows. For Lal, region is NULL, so the condition is UNKNOWN and NOT UNKNOWN is still UNKNOWN.

More DBMS and SQL questions

Exams that ask this topic