sql server:
select C1,identity(1,1) C2 from table order by c1

解决方案 »

  1.   

    oracle:
    select C1,rownum from (select C1 from table order by C1);
      

  2.   

    小狼:
    這樣做不到的.
    identity函數必須要三個參數,而且要用在select into語句中才行.
    select C1,identity(int,1,1) C2 into #temptable1 from table;
    select * from #temptable1 order by C1;Oracle中可以先新建一個序列,借助序列的nextval來達到你的要求.
      

  3.   

    我是說你的SQL Server中那樣做不到.
    Oracle很好.
      

  4.   

    Oracle:select c1,rownum 
    from (
    select c1 from table
    order by c1
    )
      

  5.   

    看来sql server还是不过关呀,也没环境,不过感觉随处都可以向各位高手学习,幸好oracle的还是对的。
      

  6.   

    MountLion(人不寐):
    select c1,rownum 
    from (
    select c1 from table
    order by c1
    )
    你这样做不行的,ORACLE不支持子查询中ORDER BY, 我也是没多久才发现这个问题. 不信你试试.
      

  7.   

    select c1,rownum from table1 order by c1;
      

  8.   

    KingSunSha(弱水三千) :
    你的版本可能不支持,我的8.1.6支持