你先構造一個表daily_day
create table daily_day( everyday date)
用于預先存放你每月的日期,如
everyday
....
2006/02/01      
2006/02/02     
2006/02/03     
2006/02/04     
2006/02/05     
2006/02/06      
2006/02/07
......
2006/02/30
.....
然後...
select everyday ,
  to_char(everyday)||'以前的次数总和'||(select count(*) from 统计表 a where a.date<=b.everyday ) as "次数"
from daily_day b以上沒測試過,只是一個想法..只供參考..

解决方案 »

  1.   

    ,
    oracle 好像有个累加函数的。
      

  2.   

    FNAME                            FDATE
    -------------------------------- -----------
    -1856233731                      2006-05-08
    2065457544                       2006-05-08
    179658652                        2006-05-08
    -607402402                       2006-05-08
    -2108581868                      2006-05-09
    1597239160                       2006-05-09
    -1053951745                      2006-05-09
    -234759422                       2006-05-10
    1929563483                       2006-05-10
    760776349                        2006-05-11
    -1360750814                      2006-05-11
    方法一:
    select s.fdate,max(s.Rid)
    From (select t.fdate, row_number() over(partition by t.fdate order by rownum) as Rid
      from tbl_temp t) s
      Group by s.fdate
    方法二:
    select t.fdate, count(t.fdate) from tbl_temp t group by t.fdate
      

  3.   

    select b.rn ri,(select count(1) from talename where "date"<=a."date") cishu
    from talename a,(select rownum+to_date('2006/02/01','yyyy/mm/dd')  rn from user_tab_cols
    where rownum<=30) b
    where b.rn=a."date"(+);
      

  4.   

    很久没有来ORACLE逛过了,现在也没环境,都不知道我写的对不对。
    应该没什么错误吧。
      

  5.   

    insert into tbl_temp (fdate,fnum) (select Add_Months(last_Day(trunc(sysdate)),-1)+1+rownum-1,rownum from dual
    connect by level<last_Day(trunc(sysdate))-(Add_Months(last_Day(trunc(sysdate)),-1))-1+1+1)
      

  6.   

    --
    insert into tbl_temp (fdate,fnum) (select Add_Months(last_Day(trunc(sysdate)),-1)+1+rownum-1,rownum from dual
    connect by level<last_Day(trunc(sysdate))-(Add_Months(last_Day(trunc(sysdate)),-1))-1+1+1)
    --
    select t.fdate, t.fnum, sum(t.fnum) over(Order by t.fdate) As FSum
      from tbl_temp t
     order by t.fdate