select (select count(1) from A where C1=t.C1 and rowid<=t.rowid) 
       ,t.*
from A t
order by t.rowid

解决方案 »

  1.   

    select row_number() over(partition by c1 order by c2) cno,c1,c2 from A;
      

  2.   

    select row_number() over(partition by c1 ) cno,c1,c2 from A;
      

  3.   

    select ROW_NUMBER() OVER (PARTITION BY C1 ORDER BY C1) ,a.* from A
      

  4.   

    select row_number() over(partition by c1 ) cno,c1,c2 from A;
      

  5.   

    如果使用row_number则应该使用rowid排序,而不是C2select row_number() over(partition by c1 order by rowid) cno,c1,c2 from A;
      

  6.   

    select c1 , c2 , row_number() over(partition by c1 order by c1 ) cno,c1,c2 from A;
    或者
    select c1 ,c2 , rank()over(partition  by name order by id )  from A ; 看楼主对重复值的排序不同使用不同的语句了