Management & CommerceVery hardBusiness analyst · SQL test
orders(oid, cust, amount) has rows (1, A, 100), (2, A, 200), (3, B, 300). items(oid, sku) lists the products in each order: order 1 has 2 items, order 2 has 1, order 3 has 3. An analyst runs SELECT SUM(o.amount) FROM orders o JOIN items i ON o.oid = i.oid to get total revenue. What does it return?
- A. 600
- B. 1300
- C. 1,400
- D. 6
Correct answer: B. 1300
The join repeats each order once per item: 100 × 2 + 200 × 1 + 300 × 3 = 1300. True revenue is 600. Joining to a 'many' table before aggregating a 'one'-side column inflates totals – aggregate first or sum from orders alone.
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- Order 1 contains SKUs x and y; order 3 contains SKUs x, y and z. Query P combines the SKU lists of the two orders with UNION; query Q uses…
- Which statement about the logical order in which a SELECT query is evaluated is correct?
- Table orders has 3 rows and table items has 6 rows. How many rows does SELECT FROM orders CROSS JOIN items return?
- Table emp(id, name, dept, salary, mgr) has rows (1, Asha, Sales, 90, NULL), (2, Ravi, Sales, 60, 1), (3, Meena, Sales, 75, 1), (4, Kiran…
- Table emp(id, name, dept, salary, mgr) has rows (1, Asha, Sales, 90, NULL), (2, Ravi, Sales, 60, 1), (3, Meena, Sales, 75, 1), (4, Kiran…
- Daily demand is a steady 50 units, the order quantity is 200 units, and the supplier's lead time is 10 days. At what on-hand stock level…