select * from table where rownum >=n1 and ronum <= n2

解决方案 »

  1.   

    SQL> select rownum,month,sell from sale where rownum=2;(1以上都查不到记录)没有查到记录
    SQL> select rownum,month,sell from sale where rownum>5;
    (由于rownum是一个总是从1开始的伪列,Oracle 认为这种条件不成立,查不到记录)
    没有查到记录 luckysxn(风花雪) 同学请注意rownum 用法
      

  2.   

    select * from (select t.*,rownum id from table)
    where id between 10 to 20
      

  3.   

    可以用
    select * from tab where rownum <= (3+1)*20 
    minus 
    select * from tab where rownum <= 3*20+1;
    但是速度不能保证。另外,我的疑问是如果你想达到这样的结果,为何
    不在表结构中加上比如象行id这样的字段,就容易
    做了。
      

  4.   

    luckysxn(风花雪) 的是错的,rownum不能那样用
    select * from (select t.*,rownum id from table t)
    where id between 10 to 20
    上面少了一个t
      

  5.   

    select * from tab where rownum <= (3+1)*20 
    minus 
    select * from tab where rownum <= 3*20+1;
    的速度没有
    select * from (select t.*,rownum id from table t)
    where id between 10 to 20
      

  6.   

    我再问一下:
    我这样写行不行:
    select * from (select t.*,rownum id from table t where "我所需的条件")
    where id between 10 to 20
      

  7.   

    我再问一下:
    我这样写行不行:
    select * from (select t.*,rownum id from table t where "我所需的条件" order by "我所需的字段")
    where id between 10 to 20
      

  8.   

    还有一个问题:
    应该是 between 10 and 20 吧?
      

  9.   

    where id>=10 and id<=20;