Management & CommerceHardBusiness analyst · SQL test
cust(id, name) has rows (1, Asha), (2, Ravi), (3, Meena), (4, Kiran), (5, Dev). ord(oid, cid, amt, dt) has rows (1, 1, 500, 2 Jan), (2, 1, 300, 5 Jan), (3, 3, 200, 3 Jan), (4, 3, 200, 3 Jan), (5, 5, 900, 4 Jan), (6, 1, 100, 9 Jan). What does SELECT cid, dt, amt, COUNT(*) FROM ord GROUP BY cid, dt, amt HAVING COUNT(*) > 1 return?
- A. No rows, because the oids differ
- B. Two rows: one for cid 1 and one for cid 3
- C. One row: cid 3, 3 Jan, 200, count 2
- D. One row: cid 1, count 3
Correct answer: C. One row: cid 3, 3 Jan, 200, count 2
Grouping by customer, date and amount puts orders 3 and 4 together (same cid, date and amount) – a likely duplicate. Customer 1's three orders differ in date and amount, so each forms its own group with count 1. oid is not in the GROUP BY, so it does not separate them.
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- cust(id, name) has rows (1, Asha), (2, Ravi), (3, Meena), (4, Kiran), (5, Dev). ord(oid, cid, amt, dt) has rows (1, 1, 500, 2 Jan), (2, 1…
- A table has 10 rows with x = 1 to 10. NTILE(4) OVER (ORDER BY x) splits them into quartile buckets. How many rows fall into buckets 1, 2…
- sal(name, dept, s) has rows: dept X – A 90, B 90, C 80, D 70; dept Y – E 60, F 50, G 50, H 40. How many rows have DENSERANK() OVER…
- An A/B test must detect a lift in conversion from 10% to 12% with α = 0.05 (two-sided) and 80% power. Using n ≈ (1.96 + 0.84)² × [p₁(1 −…
- Jobs arrive at an M/M/1 workstation at 10 per hour. Waiting (in the system) costs ₹100 per job per hour, and service capacity costs ₹40…
- Which statement correctly distinguishes the cycle-service level from the fill rate?