zoukankan      html  css  js  c++  java
  • oralce sql 分页

    create table  student (
     sid varchar2(10), --学号
     sname varchar2(10), --姓名
     classid varchar2(10), --班级号
     score  int   --分数
    );
    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  伪列进行分页:

       SELECT   t.*   FROM   (SELECT  s.*,ROWNUM rn    FROM  student s  WHERE  ROWNUM <=9)  t  WHERE  rn >= 8;



    方法二:利用分析函数;

     select * from (select t.*,row_number() over(order by SID desc) rk from student t) where rk<10 and rk>7;


  • 相关阅读:
    [BZOJ 2821] 作诗
    [P1084] 疫情控制
    [BZOJ 2243] 染色
    Session
    Jinja2 及 render_template 的深度用法
    request机制
    三件套
    初识flask
    mysql大法
    liunx命令大全
  • 原文地址:https://www.cnblogs.com/pangblog/p/3400342.html
Copyright © 2011-2022 走看看