27,581
社区成员




select p1.fentry,p1.fdate,p1.fpay,sum(p2.fpay) famount
from t_planentry p1 inner join
(select fentry,fpay from t_planentry ) p2
on p1.fentry<=p2.fentry
group by p1.fentry,p1.fdate,p1.fpay
create table tb_temp
(
id int,
date datetime,
mone int
)
insert into tb_temp
select 1,'2011-01-01',500 union all
select 2,'2011-02-01',300 union all
select 3,'2011-03-01',100 union all
select 4,'2011-04-01',100
select
calculate=(select sum (mone) from tb_temp b where b.id >= a.id)
,* from tb_temp a