你不需要insert的,@tb就是你的表名
select *, (select sum(b) from (select distinct * from @tb) as tmp1 where tmp1.a<=tmp.a) as c from (select distinct * from @tb) as tmp
sorry,如下:
Select identity(int,1,1) as id,* into #tmp from table
select a,b,(select sum(b) from #tmp where id <=tem.id) as c from #tmp tem
drop table #tmp