SQL paging statements in ORACLE

Source: Internet
Author: User

The following is a simple example of Several SQL paging statements in ORACLE. For more information, see.

The most common method is Method 1:

The Code is as follows: Copy code

Select * from (select ROWNUM as rn, Src. * from tab Src) DataSet Where rn> 10 and rn <20

Method 2:

Select * from (select ROWNUM as rn, Src. * from tab where rownum <= 150) where rn> = 100;


The result shows that the order by clause is executed after the statement becomes rownum, so the sorting result is not correct. I found an article on GOOGLE, it turns out that multiple select layers can effectively solve this problem. The statements are as follows:

The Code is as follows: Copy code

Select * from

(Select a. *, rownum row_num from

(Select * from mytable t order by t. id desc)

) B where B. row_num between 1 and 10

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.