日期:2014-05-17  浏览次数:20969 次

找按升序排列后的指定位置数据,比如只要第10个到第20个
oracle中表
create table dml.allcaseinfo(
allcasenum NUMBER primary key, 
casenum NUMBER,
historynum NUMBER
);
想实现查找按allcasenum升序排列后的指定第几个,比如只要第10个到第20个




------解决方案--------------------
select *
from (
select t.*, rownum rn
from (
select * from dml.allcaseinfo order by allcasenum asc
) t
 where rn <= 20
)
 where rn >= 10

------解决方案--------------------
SQL code

select *
  from (select emp.*, rownum r from emp where rownum < 21 order by empno)
 where r > 9;

------解决方案--------------------
oracle中表
create table dml.allcaseinfo(
allcasenum NUMBER primary key,
casenum NUMBER,
historynum NUMBER
);
想实现查找按allcasenum升序排列后的指定第几个,比如只要第10个到第20个

SQL code

select * from (select a.*,rownum rn from (select * from dml.allcaseinfo order by allcasenum asc) a)t
where rn between 10 and 20