数据库记录:
ID NumNo 要求出的结果
1  20     20
2  -8     12
3  -3     9
4  11     20
5  -4     16declare @t table(ID int,NumNo int) 
insert into @t select 1,20
insert into @t select 2,-8
insert into @t select 3,-3
insert into @t select 4,11
insert into @t select 5,-4select ID,NumNo,(select sum(NumNo) from @t where ID<=a.ID) as 要求出的结果 from @t a
ID          NumNo       要求出的结果      
----------- ----------- ----------- 
1           20          20
2           -8          12
3           -3          9
4           11          20
5           -4          16(所影响的行数为 5 行)