当前位置:数据库 > SQLServer >>

oralce sql分页

oralce sql分页
 
[sql] 
create table  student (  
 sid varchar2(10), --学号  
 sname varchar2(10), --姓名  
 classid varchar2(10), --班级号  
 score  int   --分数  
);  
[sql] 
insert into  student values('001','z001','1',80);  
insert into  student values('002','z001','1',90);  
insert into  student values('003','z001','1',70);  
insert into  student values('004','z001','1',90);  
insert into  student values('005','z001','1',80);  
insert into  student values('006','z001','1',70);  
  
insert into  student values('007','z001','2',60);  
insert into  student values('008','z001','2',70);  
insert into  student values('009','z001','2',50);  
insert into  student values('010','z001','2',70);  
insert into  student values('011','z001','2',60);  
insert into  student values('012','z001','2',50);  

 

分页方法一: 用rownum  伪列进行分页:
[sql] 
SELECT   t.*   FROM   (SELECT  s.*,ROWNUM rn    FROM  student s  WHERE  ROWNUM <=9)  t  WHERE  rn >= 8;  

 

 
 
 
 
方法二:利用分析函数;
[sql] 
select * from (select t.*,row_number() over(order by SID desc) rk from student t) where rk<10 and rk>7;  

 


CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,