Three ways to "SQL" Oracle Paging queries

Source: Internet
Author: User

Three ways to "SQL" Oracle Paging queries

Use pseudo-column rownum to query the first 10 records?
1234567891011 [sql] select * from t_user t where ROWNUM <10;  按照学生ID排名,抓取前三条记录[java] SELECT * FROM(SELECT id,realname FROM T_USER ORDER BY id asc ) WHERE ROWNUM <=3  分页SQL写法,从第10条记录开始,提取10条记录。[java] SELECT * FROM (SELECT ROWNUM rn,id,realname FROM (SELECT id,realname FROM T_USER)WHERE ROWNUM<=20) t2 WHERE T2.rn >=10;  按照学生ID排名,从第10条记录开始,提取10条记录。[sql] SELECT * FROM (SELECT ROWNUM rn,id,realname FROM (SELECT id,realname FROM T_USER ORDER BY id asc)WHERE ROWNUM<=20) t2 WHERE T2.rn >=10;

"Note" 1.?
1 whererownum>1
Cannot crawl to record. 2.?
1 whererownum between 2 and10
Nor can the record be crawled. Using the Analytic function row_number () over (the ORDER by field)?
1234567891011121314 按照学生ID排名,抓取前三条记录[sql] SELECT * FROM(SELECT id,realname,row_number()over(ORDER BY id asc) rn FROM T_USER)WHERE rn <=3  按照学生ID排名,从第10条记录开始,提取10条记录。[sql] SELECT * FROM(SELECT id,realname,row_number()over(ORDER BY id asc) rn FROM T_USER)WHERE rn BETWEEN 10 AND 20  运用minus方法从第10条记录开始,提取10条记录。[java] SELECT * FROM T_USER WHERE ROWNUM<20 MINUS SELECT * FROM T_USER WHERE ROWNUM<10;  按ID排序后,从第10条记录开始,提取10条记录。[sql] (SELECT * FROM (SELECT * FROM T_USER ORDER BY id asc) WHERE ROWNUM<20)  MINUS( SELECT * FROM (SELECT * FROM T_USER ORDER BY id asc) WHERE ROWNUM<10);

Three ways to "SQL" Oracle Paging queries

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.