Management & CommerceHardBusiness analyst · SQL test
Table m(store, mon, rev) has S1: month 1 = 100, month 2 = 120, month 3 = 90; S2: month 1 = 200, month 2 = 180. What does rev − LAG(rev) OVER (PARTITION BY store ORDER BY mon) give for S2's month 1 and month 2?
- A. plus 110 and minus 20
- B. 0 and minus 20
- C. NULL and minus 20
- D. NULL and 180
Correct answer: C. NULL and minus 20
LAG looks at the previous row within the same partition. S2's first month has no previous S2 row, so LAG is NULL and the difference is NULL – it does not borrow S1's month 3 (90). Month 2 gives 180 − 200 = −20.
Practise more Operations, Supply Chain & Business Analytics questionsOperations, Supply Chain & Business Analytics: notes and key points
More Operations, Supply Chain & Business Analytics questions
- Using table v (where Goa's only row has amt NULL), what do SELECT SUM(amt) FROM v WHERE city = 'Goa' and SELECT COALESCE(SUM(amt), 0) FROM…
- A subscription business started the quarter with 1,000 customers, gained 200 new customers during the quarter and ended with 1,050…
- While solving a transportation problem with 3 sources and 4 destinations, an initial solution has only 5 occupied cells. What should be…
- In the Hungarian method for a 5 × 5 assignment problem, after row and column reductions all zeros can be covered by 4 lines. What does…
- A plant runs at 80% utilisation and its average queue of jobs is 4 hours of work. Management plans to load it to 95% utilisation. Assuming…
- A supply chain shares point-of-sale data and builds a joint forecast with its retailer, agreeing on replenishment plans together. Which…