Management & CommerceHardBusiness analytics · SQL · MBA placement
Table ord(cust, day) has rows (A, 1), (A, 5), (A, 12), (B, 3), (B, 4). What does this query return? SELECT AVG(gap) FROM (SELECT LEAD(day) OVER (PARTITION BY cust ORDER BY day) − day AS gap FROM ord) t;
- A. 2.4
- B. 4
- C. 2.75
- D. 3.25
Correct answer: B. 4
Gaps: A → 4, 7, NULL; B → 1, NULL. AVG ignores NULLs: (4 + 7 + 1)/3 = 4. Treating NULLs as 0 gives 2.4; leaving out PARTITION BY gives 2.75; averaging each customer first gives 3.25.
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- cust has rows (1, Asha), (2, Ravi), (3, Meena). ord(oid, cid, status) has (10, 1, 'paid'), (11, 1, 'due'), (12, 2, 'due'). How many rows…
- orders(oid, cust, amount): (1, A, 100), (2, A, 200), (3, A, 600), (4, B, 300), (5, B, 500), (6, C, 900). How many rows does this return?…
- A1 holds 95. What does =IFS(A1>=50, "C", A1>=70, "B", A1>=90, "A", TRUE, "F") return?
- x values 2, 4, 6, 8, 10 are in A2:A6 and y values 30, 34, 35, 41, 45 in B2:B6. What does =FORECAST.LINEAR(12, B2:B6, A2:A6) return?
- A spare part sells in only about one week out of five, but when it does, it sells 3–20 units. A simple exponential-smoothing forecast…
- A distributor classifies SKUs not only by annual value (ABC) but also by how variable their demand is: steady (X), fluctuating (Y) and…