Home Forums SQL Server 7,2000 T-SQL Interesting problem for the "Running Total/Quirky Update" method of removing cursors RE: Interesting problem for the "Running Total/Quirky Update" method of removing cursors

  • Thanks for the input guys. The rows need to be calculated in dayid desc order. Here are the expected results.

    AssetID_inSymbolDayID_inMV DailyPerf RunningPerf

    100IBM75006NULL201048.89870.0010323210.001032321

    100IBM75005NULL200841.56580.0025951330.003630133

    100IBM75004NULL200321.7043-0.003969482-0.000353759

    100IBM75003NULL201120.0467-0.003270067-0.003622669

    100IBM75002NULL201779.88050.000637183-0.002987795

    100IBM75001NULL201651.39170 -0.002987795

    100IBM75000NULL201651.39170 -0.002987795

    It's a bit odd because you need to start on the second row (Todays MV - Yesterdays MV divided by Yesterdays MV) to get the first rows performance but the running is done first row to second row. So 75006 Daily is (201047.8987-200841.5658)/200841.5658 and running is 1 + Current Running (which is 0 on day 75006) * 1 + Daily minus 1. I realize the Running Performance seems backwards meaning that the value for the entire period is actually stored on the first day of the period, but this is done for a reason which is more than you probably want to know about calculating market performance for periods.... anyway hope this calrifies a little more.