标签:
--------------------------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