CS FundamentalsModerateTCS Digital · Infosys SP · GATE CS

Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4, 'Dev', 'Tech', NULL, 3), (5, 'Esha', NULL, 35, 3), (6, 'Farid', 'Tech', 70, 2). What does this query return?

Table Staff(id, name, dept, pay, boss) rows: (1, 'Anu', 'Ops', 40, NULL), (2, 'Bala', 'Ops', 55, 1), (3, 'Chitra', 'Tech', 70, 1), (4, 'Dev', 'Tech', NULL, 3), (5, 'Esha', NULL, 35, 3), (6, 'Farid', 'Tech', 70, 2). What does this query return?
SELECT COUNT(*) FROM Staff WHERE dept <> 'Ops';
  1. A. 2
  2. B. 4
  3. C. 6
  4. D. 3

Correct answer: D. 3

Chitra, Dev and Farid are in Tech. Esha's dept is NULL, and NULL <> 'Ops' is UNKNOWN, so her row is filtered out: 3, not 4.

More DBMS and SQL questions

Exams that ask this topic