I am trying to build a output table as given below. Can some one please help how I can use the lag lead or some other window function to solve it?
Start= End from previous month
Net= new- churn
End = Start + Net
INPUT
month year new churn
2 2012 114 0
3 2012 143 20
4 2012 221 43
5 2012 197 74
6 2012 234 122
7 2012 276 138
8 2012 278 200
OUTPUT
month year Start new churn Net End
2 2012 0 114 0 114 114
3 2012 114 143 20 123 237
4 2012 237 221 43 181 418
5 2012 418 197 74 125 543
6 2012 543 234 122 116 659
7 2012 659 276 138 150 809
8 2012 809 278 200 90 899