• Prakash

    What question are you asking here - how to do running totals, or how to change how they're partitioned at run time?

    The answer to the first question is to use the window functions, something like this (from memory, so forgive any syntax errors):

    SUM(Value) OVER (PARTITION BY Region ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)

    The answer to the second question is that you can't do that, as far as I know, without using dynamic SQL.

    John