I am trying to get a running subtotal (understanding this is different from subtotals for groups, and the rollup approach).
Tried using
Row_Number() over (order by ID_Number) as Row_Count
and nesting it in select statements and using a LEFT OUTER JOIN on itself (which just churns).
What I am trying to get is this:
if ROW_COUNT > 1 THEN RUNNINGTOTAL = Volume_Category + (RUNNINGTOTAL for ID_Number where ROW_COUNT= ROW_COUNT(for this ID_Number*)-1)
I have a table with a list of unique "ID-Numbers" which are the focus here.
sumfunction.UPDATE SET @var = Total = @var + value) is not guaranteed to process in any specific order, even if that's what you observe. Please see sqlperformance.com/2012/07/t-sql-queries/running-totals for some details on this.