CS FundamentalsHardWipro · Cognizant technical pattern

Table Orders(id, cust, city, amount) rows: (1, 'Ana', 'Pune', 500), (2, 'Ben', 'Delhi', NULL), (3, 'Ana', 'Pune', 300), (4, 'Chen', 'Delhi', 700), (5, 'Dia', NULL, 200), (6, 'Ben', 'Delhi', 700). What does this query return?

Table Orders(id, cust, city, amount) rows: (1, 'Ana', 'Pune', 500), (2, 'Ben', 'Delhi', NULL), (3, 'Ana', 'Pune', 300), (4, 'Chen', 'Delhi', 700), (5, 'Dia', NULL, 200), (6, 'Ben', 'Delhi', 700). What does this query return?
SELECT COUNT(*) FROM Orders
WHERE amount > 250 OR amount <= 250;
  1. A. 6
  2. B. 4
  3. C. 0
  4. D. 5

Correct answer: D. 5

The condition looks like a tautology, but for row 2 (amount NULL) both comparisons are UNKNOWN, and UNKNOWN OR UNKNOWN is UNKNOWN, so the row is filtered out. 5 rows remain. 6 assumes two-valued logic.

More DBMS and SQL questions

Exams that ask this topic