日期:2014-05-17 浏览次数:20693 次
with tb(月份,金额)as(
select 1,20000 union all
select 2,30000 union all
select 3,5000
)
select *,(
select SUM(a.金额) from tb a,tb b
where a.月份<=b.月份 and b.月份=c.月份
group by b.月份) 累计金额
from tb c
with tb(月份,金额)as(
select 1,20000 union all
select 2,30000 union all
select 3,5000
)
select 月份,金额,(select sum(金额) from tb t2 where t2.月份<=t1.月份) 累计金额
from
tb t1