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

  

posted @ 2014-09-04 11:19  Toby Wang  阅读(463)  评论(0编辑  收藏  举报