select * from table where rownum<=10
minus
select * from table where rownum<5

解决方案 »

  1.   

    select * from (select rownum rm,a.* from table a where....) where rm>=5 and rm<=10;
      

  2.   

    select * from
      where rowid in
        (select rowid from table1 where rownum<=10
         minus
         select rowid from table1 where rownum<5)
    -----------------------------------------------
    select * from 
      (select rownum rn,a.* from table1 a)
      where rn between 5 and 10
      

  3.   

    谢谢大家。但我这条sql语句是想能在多个数据库中运行。而伪列rownum 
    好像是oracle独有的吧。比如说在postgresDB中好像就不行。
    能不能有通用的写法