select rownum, field1 from table1

解决方案 »

  1.   

    可是这样 field1字段就会有重复的了
    加distinct也不行
      

  2.   

    select rownum, field1 from (select distinct field1 from table1)
      

  3.   

    select tab.rn,tab.id from (select distinct field1 id,rownum rn from table1) tab;
      

  4.   

    to BlueskyWide(谈趣者):
    你的这个方法与“select rownum, field1 from table1”效果是一样的
      

  5.   

    To Michaelyfj(星星还是那颗星星):
    受你影响,还是这句(调换一下次序)最简洁:
    select distinct field1,rownum from table1;
      

  6.   

    to BlueskyWide(谈趣者):
    如果field1有重复,也会查找出来,不符合楼主意图
      

  7.   

    To Michaelyfj(星星还是那颗星星):
    如果field1为别名的怎么查啊
    就像to_char(date,'yy')"yy"  就无法再select yy 了
      

  8.   

    你用select "yy" 就行了,不要用select yy
    当然,还有一种办法就是你的to_char(date,'yy') "yy"改为
    to_char(date,'yy') yy,你就可以使用select yy 或select YY,也就是你在取别名时,不加""号
      

  9.   

    select rownum, field1 field1||rownum from (select distinct field1 from table1)