SQL结果集累加

if OBJECT_ID('tempdb..#linshi') is not null
drop table #linshi
SELECT id=identity(int,1,1), Cost
into #linshi
FROM XXXX
Order By Cost Desc select * ,count=( select sum(Cost) from linshi i where i.id<o.id ) from #linshi o

  

原文地址:https://www.cnblogs.com/yixiaozi/p/3955662.html