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). Table customers(name, tier) has 4 rows: (Asha, Gold), (Ravi, Silver), (Kiran, Gold), (John, Bronze). What does SELECT c.name, COUNT(o.order_id) FROM customers c LEFT JOIN orders o ON c.name = o.customer GROUP BY c.name; return?
- A. 4 rows, with Kiran showing 0
- B. 5 rows, including Meena with 2
- C. 3 rows; Kiran does not appear
- D. 4 rows, with Kiran showing 1
Correct answer: A. 4 rows, with Kiran showing 0
A LEFT JOIN keeps every customer. Kiran has no orders, so the joined row has NULL order_id, and COUNT(o.order_id) gives 0 (COUNT(*) would wrongly give 1). Meena is not in customers, so she does not appear. Result: Asha 2, Ravi 2, Kiran 0, John 1.
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…
- Table orders(orderid, customer, region, amount) has 7 rows: (1, Asha, North, 500); (2, Ravi, South, 300); (3, Asha, North, 200); (4…
- Table orders(orderid, customer, region, amount) has 7 rows: (1, Asha, North, 500); (2, Ravi, South, 300); (3, Asha, North, 200); (4…
- 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…