CS FundamentalsModerateTCS NQT · Infosys · Product-company placement

Ord(oid, cid, amt) has rows (10, 1, 500), (11, 1, NULL), (12, 2, 300), (13, NULL, 200), (14, 5, 100). What does SELECT COUNT(*), COUNT(DISTINCT cid), AVG(amt) FROM Ord; return?

  1. A. 5, 4, 275
  2. B. 4, 3, 275
  3. C. 5, 3, 220
  4. D. 5, 3, 275

Correct answer: D. 5, 3, 275

COUNT(*) counts all 5 rows. COUNT(DISTINCT cid) ignores the NULL, giving {1, 2, 5} = 3. AVG ignores the NULL amount: 1100 / 4 = 275, not 1100 / 5 = 220.

More DBMS and SQL questions

Exams that ask this topic