assumption : Your running total table must have sequence column like datetimecreate table #temp( symbol varchar(10), total integer, seq int identity(1,1))insert into #temp (symbol, total)select 'MSFT', 100 union allselect 'MSFT', 500 union allselect 'MSFT', 700 union allselect 'MSFT', 800 union allselect 'AA', 100 union allselect 'AA', 300 union allselect 'MSFT', 850 union allselect 'AA', 400select symbol, total - isnull((select top 1 total from #temp x where x.symbol = t.symbol and x.seq < t.seq order by seq desc), 0)from #temp torder by seq
-----------------[KH]