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). Which customers does SELECT customer, SUM(amount) FROM orders GROUP BY customer HAVING SUM(amount) > 600; return?

  1. A. Ravi (700) only
  2. B. Asha (700) and Ravi (1000)
  3. C. Asha (700), Ravi (1000) and John (400)
  4. D. Ravi (1000) only

Correct answer: B. Asha (700) and Ravi (1000)

Totals: Asha 500 + 200 = 700; Ravi 300 + 700 = 1,000; Meena 350 (NULL ignored); John 400. HAVING keeps groups whose total exceeds 600: Asha and Ravi. 'Ravi (700) only' is what a row-level filter (WHERE amount > 600) would give.

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic