Management & CommerceModerateBusiness analyst · SQL test

For the same logins table (6 rows: A has 3 logins, B has 2, C has 1; 4 are on 'app'), what does SELECT COUNT(DISTINCT cust), COUNT(*), SUM(CASE WHEN device = 'app' THEN 1 ELSE 0 END) FROM logins return?

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

Correct answer: B. 3, 6, 4

COUNT(DISTINCT cust) counts unique customers (3); COUNT(*) counts rows (6); the CASE expression turns each 'app' row into 1, so the SUM counts app logins (4). This SUM(CASE…) pattern is how analysts pivot categories into columns.

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic