I am doing a query in which the results of a previous row calculation are used in the next row calculation (recursive I guess).
For example the results should look like this:
Item
Loc
Week
A
B
C
Inventory (Prev Inv + A + B - C)
1111
aaaa
201301
100
40
60
80
First time prev inv is null
1111
aaaa
201302
30
200
100
210
So I can use
MIN(Inventory) OVER(ORDERBY item, loc, week ROWSBETWEEN 1 PRECEDINGAND 1
PRECEDING) as PrevInv
And the second row will be good (PrevInv + A + B – C)
However on the rest of the rows I cannot use the previous row's created Inventory value.
Forums: