select * from (select  * from stu where id not in (select top 4 id from stu order by id) order by id) where rownum<3;

解决方案 »

  1.   

    to:bzszp(SongZip)我用的ORACLE8.1.7,好像不支持top语句吧!SQL> select * from stu;        ID NAME       SEX        DEPTCODE
    ---------- ---------- ---------- ----------
             1 燕子       女         D001SQL> select top 1 * from stu;
    select top 1 * from stu
               *
    ERROR 位于第 1 行:
    ORA-00923: 未找到预期 FROM 关键字
      

  2.   

    1、你的语句在SQL SERVER中能通过,但结果不一定是正确的。因为order by 不能与top在同1条查询中出现。
    2、同里。在oracle中,用rownum伪列能通过,但结果不一定是正确。
    3、oracle中取前2条的语法例
    select * from table where rownum<3;
      

  3.   

    sorry,没注意后面的
    select * from (select  * from stu where id not in (
    select * from(select  id from stu order by id) where rownum<5) order by id) where rownum<3;
      

  4.   

    TO:qiyousyc(沈阳棋友)"结果不一定是正确的"?不太理解!在SQL SERVER中order by 应该可以与top同用的.其实,我写上面的SQL语句,想实现在分页时,每次只从数据库中取出要显示的记录,比如,每页显示10笔,则只从数据库中取出10笔.以前在SQL SERVER中可以实现,现在在ORACLE却不知道怎么实现?