Possible Duplicate:
Calculate a Running Total in SqlServer
I'm trying to calculate the cummulative return without using a cursor. I'm using SQL Server 2005.
The calculation in the cursor is as follows:
SET @CumRtn = (@CumRtn * (1 + @PeriodRtn))
Here is the data with the correctly calculated Cummulative Return.
0 A B C D
1 ValueDate PeriodReturn CummulativeRtn Excel Formula
2 31-May-96 100 100 100
3 30-Jun-96 0.00672617 100.672617 =D2 * (1+B3)
4 31-Jul-96 -0.0473345 95.90732905 =D3 * (1+B4)
5 31-Aug-96 0.014525272 97.30040907 =D4 * (1+B5)
6 30-Sep-96 0.049063368 102.0742949 =D5 * (1+B6)
7 31-Oct-96 0.005499141 102.6356158 =D6 * (1+B7)
8 30-Nov-96 0.055675119 108.3498659 =D7 * (1+B8)
So far I haven't had much luck reproducing the numbers above, any ideas?
Let me know if I can provide any further data.
Thanks, Patrick