ITPub博客

首页 > 应用开发 > IT综合 > rownum 的用法(原)

rownum 的用法(原)

原创 IT综合 作者:wsf3809 时间:2007-07-25 09:46:51 0 删除 编辑

今天在看一个分页算法的时候,遇到一个奇怪的问题,经过群内bq 的指点偶明白了。

select aa.*,aa.rn from
(select a.*,rownum rn from
(select * from hr_employee t where t.outdate is null order by 1) a
where rownum <20) aa
where aa.rn>10


select a.*,rownum rn from
(select * from hr_employee t where t.outdate is null order by 1) a
where rownum >20
and rownum <10

这个2个语句的写法,如果按照正常思维肯定是第二个写法,恰恰就是这个错了,rownum不能直接使用> 不然取不出结果集。学习一下!

昨天咋看一个分页算法的时候一直很纳闷,为啥rownum那边不可以写大于呢。原来如此。

[@more@]

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/700806/viewspace-927877/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    36
  • 访问量
    46481