Oracle Select Limit Method ____oracle

Source: Internet
Author: User

Select a row in a table: (Understanding: RowNum is an Oracle system order is assigned the number of rows returned from a query)SELECT * FROM (select RowNum a,t.* from Testtab t) where a=2;Cannot be:SELECT * FROM (select rownum,t.* from Testtab t) where rownum=2 or select * from Testtab where rownum=2;Return multiple lines of records:SELECT * from Testtab where rownum<=10;Returns a segment of a record: (for example, 4-10 rows in a record table)SELECT * FROM (select RowNum no,testtab.* from Testtab where rownum<=10) where no>=4;Returns a conditional, sorted record of a segment:Select RowNum num1,tt.* from (select RowNum num,t.* from (select Ecodeinfo.* to Ecodeinfo where a=1 order by Ecode D ESC) t) TT where NUM>19 and rownum<20>Oracle is the first to extract records and then sorted, and Oracle's rownum is generated in the extraction record, which is preceded by the sort operation, so the subquery must be sorted first. Cannot be:SELECT * from Tsettab where rownum>10;Returns the last line of records:SELECT * FROM (select RowNum a,t.* to Testtab T) where a= (select COUNT (*) from testtab);Returns the last N row record:SELECT * FROM (select RowNum a,t.* from Testtab t) where a= (select COUNT (*)-n from Testtab);----------------SELECT * from Adminrole where rownum<=4 minus select * from Adminrole where rownum<2>SELECT * FROM (select RowNum row_id, b.* from (select A.* to sorttable a order by SortID) b) where row_id between 5 and 9 ;

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.