insert into t1 values(to_date('20130101','yyyymmdd'),(select count(*)+1 from t1 where t1.time=to_date('20130101','yyyymmdd')));

解决方案 »

  1.   


    --sql:
    update tab_time t
       set num =
           (select t3.cnt
              from (select row_number() over(partition by t2.time order by t2.rowid) as cnt,
                           rowid as rid
                      from tab_time t2) t3
             where t3.rid = t.rowid)
    --result:
    SQL> select * from tab_time;
     
    TIME            NUM
    -------- ----------
    20130101          1
    20130101          2
    20130102          1
    20130102          2
    20130102          3
    20130103          1
      

  2.   

    #2威武但是感觉,你的需求有点问题,按时间分组,是不是还应该按其他字段排序,这么随机排序不太好吧。
    可以在排序处换一下你想要的
    row_number() over(partition by t2.time order by t2.xx)