¶àл£¡£¡£¡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
¹ØÓÚSQL Server Mobile Edition ÓÃMicrosoft SQL Server2005 Management Studio Express9.00.3042.00´´½¨SQLCEÊý¾Ý¿âsqlmobile.sdf ÔÚmobileϵͳÖÕ¶ËÉÏÓÃSQL Server Mobile Edition3.0Äܲ鿴sqlmobile.sdfÀï±íÊý¾Ý ......