表形式如下:
Year       Salary
2000        1000
2001        2000
2002        3000
2003        4000
想得到如下形式的查询结果
Year       Salary
2000       1000
2001       3000
2002       6000
2003       10000
sql语句怎么写?

解决方案 »

  1.   

    你的另外一个帖子不是有人帮你解决了吗?
    10楼的fffff_1982:
    利用子查询可以实现 
    create table  #a 
    (Year int  
    ,  Salary int ) insert into #a 
    select '2000','1000' 
    union 
    select '2001','2000' 
    union 
    select '2002','3000' 
    union 
    select 
    '2003','4000 ' 
    select year , (select sum (Salary) from #a  where year <=b.year)    from  #a  b