Eric Gibson wrote: > I need a function similar to the SQL SUM function, but instead of each row > containing a sum of all rows selected by the query, I need a running total > of all rows up to and including the current row. For instance, I may want to > list the number of hours worked by an employee for 2003, for each month, > including a running total of all months up to the current month.
Basically, you want a subtotal with each row. It sounds like a common action to take, so there ought to be some type of accumulator in SQL. I don't know the answer. All the reporting tools layered over SQL have subtotals. With your stored procedure, you can try looking at %ROWCOUNT to determine when the query begins. But as you say, the stored proc technique is tedious and error prone.
