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

  • I'm still a little unclear on your requirements. Can you provide the results you are trying to get?

    This is a guess and might be the whole thing you're trying to avoid, but what about changing the sort order to ASC on day_id and then using this:

    update #DMVRunningPerformance

    set

    @DailyPerformance=DailyPerf=CASE WHEN @NewGroup_bt=1 THEN 0 ELSE

    (MV - @NDMarketValue)/ @NDMarketValue END,

    @RunningPerformance=RunningPerf=CASE WHEN @NewGroup_bt=1 THEN 0 ELSE

    ((1 + @RunningPerformance) * (1 + @DailyPerformance)) - 1 END,

    @NDMarketValue=MV,

    @NewGroup_bt=0

    FROM #DMVRunningPerformance OPTION (MAXDOP 1)

    Seth Phelabaum


    Consistency is only a virtue if you're not a screwup. 😉

    Links: How to Post Sample Data[/url] :: Running Totals[/url] :: Tally Table[/url] :: Cross Tabs/Pivots[/url] :: String Concatenation[/url]