Management & CommerceVery hardBusiness analyst · KPO · MBA placement pattern

Table orders(order_id, customer, region, amount) has 7 rows: (1, Asha, North, 500); (2, Ravi, South, 300); (3, Asha, North, 200); (4, Meena, East, NULL); (5, Ravi, South, 700); (6, John, North, 400); (7, Meena, East, 350). What does SELECT region, COUNT(*) FROM orders WHERE amount > 250 GROUP BY region HAVING COUNT(*) >= 2; return?

  1. A. North 2, South 2 and East 1
  2. B. North 3 and South 2
  3. C. South 2 only
  4. D. North 2 and South 2

Correct answer: D. North 2 and South 2

WHERE runs first and keeps amounts above 250: orders 1 (N), 2 (S), 5 (S), 6 (N) and 7 (E); order 3 (200) and the NULL fail. Groups: North 2, South 2, East 1. HAVING COUNT(*) ≥ 2 drops East. North 3 counts order 3, which WHERE has already removed.

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic