Management & CommerceModerateBusiness 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 happens when SELECT region, SUM(amount) FROM orders WHERE SUM(amount) > 500 GROUP BY region; is run?

  1. A. It raises an error, as aggregates such as SUM cannot appear in WHERE
  2. B. It returns all three regions, as WHERE is ignored once GROUP BY is used
  3. C. It returns South only, keeping just the row with amount above 500
  4. D. It returns North and South, the two regions whose totals exceed 500

Correct answer: A. It raises an error, as aggregates such as SUM cannot appear in WHERE

WHERE filters individual rows before grouping, so it cannot refer to SUM(). North and South (totals 1,100 and 1,000) are what … GROUP BY region HAVING SUM(amount) > 500 would return; reading the condition as a row filter (amount > 500) would keep only South.

More Operations, Supply Chain & Business Analytics questions

Exams that ask this topic