码迷,mamicode.com
首页 > 其他好文 > 详细

分页查询

时间:2015-09-11 22:14:04      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:

--------------------------oracle

1.select * from (
       select tb1.*,rownum rn from (
              select * from flow_task order by serialno
       ) tb1
       where rownum < 40
) tb2
where tb2.rn >30;

2.select * from (
       select tb1.*,rownum rn from (
              select * from flow_task order by serialno
       ) tb1
) tb2
where tb2.rn between 30 and 40;

注:对比这两种写法,绝大多数的情况下,第一个查询的效率比第二个高得多。

------------------------DB2

select * from (
        select tb1.*,rownumber()over() as rn from (
               select * from lc_appl order by appl_cde
        ) tb1
)tb2
where tb2.tn between 30 and 40;

 

分页查询

标签:

原文地址:http://www.cnblogs.com/jiaolj/p/4802095.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!