select identity(int,1,1) ID,a.* into #t1 from ta_test aselect name,(select sum(persent) from #t1 where ID<=a.ID) as persent
from #t1 a

解决方案 »

  1.   

    select identity(int,1,1) id, * into #t from ta_testselect [name],(select sum(persent) from #t where id<=a.id ) persent
    from #t a
      

  2.   

    select * into #temp from ta_test
    declare @a numeric(10,2)
    set @a=0
    update #temp set @a=@a+persent,persent=@a
    select * from #temp
      

  3.   

    select * into #temp from ta_test
    declare @a numeric(10,2)
    set @a=0
    update #temp set @a=@a+persent,persent=@a
    select * from #temp
      

  4.   

    SELECT name,
              (SELECT SUM(persent)
             FROM test1 a
             WHERE a.name <= b.name) AS addpersent
    FROM test1 b