多谢!!!nobody knows? select id,month,sum(num) over (order by id,month) num from table; 学习 如果还有分类,怎么累计?多谢回复 1 2010-01 120 a 2 2010-02 200 a 3 2010-03 400 b
1 2010-01 120 a 2 2010-02 320 a 3 2010-03 400 b select id,month,sum(num) over (partition by type order by id,month) num,type from table; SQL code: with temp as( select 1 id,to_date('2010-01','yyyy-mm') date1,120 num from dual union all select 2 id,to_date('2010-02','yyyy-mm') date1,200 num from dual union all select 3 id,to_date('2010-03','yyyy-mm') date1,400 num from dual union all select 4 id,to_date('2010-03','yyyy-mm') date1,400 num from dual ) select date1,sum(num) over(partition by date1 order by id,date1) total from temp