CS FundamentalsModerateGATE 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 amt BETWEEN 450 AND 300;

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

Correct answer: C. 0

x BETWEEN a AND b means x >= a AND x <= b, and no amount is both >= 450 and <= 300, so 0 rows. BETWEEN is not symmetric unless written BETWEEN SYMMETRIC; the swapped bounds would count 4.

More DBMS and SQL questions

Exams that ask this topic