[]oracle to query a record of a specified number of rows

Source: Internet
Author: User

Oracle uses virtual column rownum to query the number of records between a specified number.

The first line of Rownum=1

For example, we want to query the first five records, you can use

SELECT * FROM table name where rownum<5.

But if we use rownum>5, we will make mistakes, and then we have to change the method.

Select Column name from
(select RowNum r, column name from EMP)
where r>5

For example, if we want to query an EMP table for a salary of 6-9 of the employees, then

Select Ename,sal from
(
Select Ename,sal,rownum r from (select Ename,sal from emp order BY sal Desc)
)
where R>5 and r<10

[]oracle to query a record of a specified number of rows

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.