第一句SQL:
select s.*  from ( select this_.STCD as STCD1_0_, this_.TM as TM1_0_  from ST_RIVER_R this_ order by this_.TM desc ) s where ROWNUM>0 AND rownum <= 10
第二句SQL:
select s.*  from ( select this_.STCD as STCD1_0_, this_.TM as TM1_0_  from ST_RIVER_R this_ order by this_.TM desc ) s where  rownum <= 10
如上述,查询出的解决竟然有所不同,查询期间未有任何的填删改操作,希望大家能帮忙给个解释谢谢!!!!!

解决方案 »

  1.   

    有意思。应该是SQL语句在执行时被重排的影响。如果你有执行计划分析工具的话,可以把两者的执行计划列出来,我相信绝对是不同的,主要应该是过滤条件执行位置发生变化。
    所以强调不能直接用rownum进行分页,必须先固化,再分页!select s.* from ( 
      select this_.STCD as STCD1_0_, this_.TM as TM1_0_, rownum as rn_ from ST_RIVER_R this_ order by this_.TM desc 
    ) s 
    where rn_>0 AND rn_<= 10