日期:2014-05-17 浏览次数:20481 次
select b.rq,b.jz,b.cz,SUM(a.total) as total from
(
select rq,jz,cz,jz-cz as total from
(
select [日期] as rq,SUM([进账]) as jz,SUM([出账]) as cz
from tb group by [日期]
) tt
) a
cross join
(
select rq,jz,cz,jz-cz as total from
(
select [日期] as rq,SUM([进账]) as jz,SUM([出账]) as cz
from tb group by [日期]
) tt
) b where b.rq>=a.rq
group by b.rq,b.jz,b.cz