Management & CommerceHardBusiness analyst · SQL test

Table v(cust, city, amt) has rows (A, Pune, 100), (B, NULL, 200), (C, Pune, 50), (D, Goa, NULL), (E, NULL, 80). What does SELECT COUNT(DISTINCT city), COUNT(city), COUNT(*) FROM v return?

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

Correct answer: A. 2, 3, 5

COUNT(DISTINCT city) counts distinct non-NULL values: Pune and Goa (2). COUNT(city) counts non-NULL entries (3). COUNT(*) counts rows (5). NULL is never counted as a distinct value.

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic