update tablename t1
set c=(select count(*) 
       from tablename t2 
       where t2.col_a=t1.col_a and t2.col_b<=t1.col_b)

解决方案 »

  1.   

    结果好像不太对,我试了一下icevi(按钮工厂)的方法:
    SQL> select * from ta_1;A   B          C
    --- - ----------
    aaa a          1
    aaa b          2
    aaa c          3
    bbb a          1
    bbb x          3
    bbb d          2不知 K999 (拼死也当程序员 !)  想实现什么功能.
    我感觉应该是以col_1,col_2分组,每组的col_3均赋予1,2,3..6 rows selected.
      

  2.   

    ok:10:10:15 SQL> update jl t1
    10:20:10   2  set c=(select count(*) 
    10:20:10   3         from jl t2 
    10:20:10   4         where t2.col_a=t1.col_a and t2.rowid<=t1.rowid);已更新6行。已用时间:  00: 00: 00.40
    10:20:10 SQL> commit;提交完成。已用时间:  00: 00: 00.10
    10:20:10 SQL> select * from jl;COL_A      COL_B               C
    ---------- ---------- ----------
    aaa        a                   1
    aaa        b                   2
    aaa        c                   3
    bbb        a                   1
    bbb        x                   2
    bbb        d                   3
      

  3.   

    做梦也想证明歌德巴赫猜想的先生,我的问题可还没解决完!!!
    http://www.csdn.net/expert/topic/640/640398.xml?temp=.1933557
      

  4.   

    http://www.csdn.net/expert/topic/640/640398.xml?temp=.1933557
      

  5.   

    已经搞定:drop table jlandzpa;
    create table jlandzpa(a varchar2(10),b varchar(10));
    insert into jlandzpa values('1','0');
    commit;
    create or replace procedure p_jlandzpa as
    cursor c1 is
    select a,rowid from jlandzpa;
    s_a  varchar2(20);
    s_rowid varchar2(20);
    begin
           open c1;
           fetch c1 into s_a,s_rowid;
           loop
             update jlandzpa set b = '1' 
                where rowid = chartorowid(s_rowid);
             commit;
            fetch c1 into s_a,s_rowid;
            exit when c1%notfound;
            end loop;
            close c1;
    end;
    /
    exec p_jlandzpa;
    select * from jlandzpa;
    10:57:08 SQL> select * from jlandzpa;A          B
    ---------- ----------
    1          0exec p_jlandzpa;
    select * from jlandzpa;
    10:57:52 SQL> select * from jlandzpa;A          B
    ---------- ----------
    1          1