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). For customer 1, what running totals does SUM(amt) OVER (PARTITION BY cid ORDER BY dt) give for orders 1, 2 and 6, in date order?
- A. 500, 800, 900
- B. 500, 300, 100
- C. 900, 900, 900
- D. 100, 400, 900
Correct answer: A. 500, 800, 900
Partitioned by customer and ordered by date, the window sums all earlier rows plus the current one: 500; 500 + 300 = 800; 800 + 100 = 900. Without ORDER BY the window would be the whole partition (900 on every row).
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- 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?
- A one-person repair shop treats jobs on a first-come basis. Its owner proposes giving priority to short jobs (shortest processing time…