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?
- A. It raises an error, as aggregates such as SUM cannot appear in WHERE
- B. It returns all three regions, as WHERE is ignored once GROUP BY is used
- C. It returns South only, keeping just the row with amount above 500
- 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.
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- Table orders(orderid, customer, region, amount) has 7 rows: (1, Asha, North, 500); (2, Ravi, South, 300); (3, Asha, North, 200); (4…
- A consumer-electronics firm's quarterly figures (₹ crore unless stated), Q1 to Q4: revenue 240, 270, 300, 330; cost of goods sold 150…
- A consumer-electronics firm's quarterly figures (₹ crore unless stated), Q1 to Q4: revenue 240, 270, 300, 330; cost of goods sold 150…
- A consumer-electronics firm's quarterly figures (₹ crore unless stated), Q1 to Q4: revenue 240, 270, 300, 330; cost of goods sold 150…
- A consumer-electronics firm's quarterly figures (₹ crore unless stated), Q1 to Q4: revenue 240, 270, 300, 330; cost of goods sold 150…
- A distributor's three warehouses last year: W1 shipped 12,000 orders (11,280 on time), held average inventory of ₹80 lakh and handled COGS…