Select a row of records in the Table: (understanding: rownum is the number of rows sequentially allocated from the query returned by the Oracle System)
Select * from (select rownum A, T. * From testtab t) where a = 2;
Select * from (select rownum A, T. * From testtab t) where a = 3;
Select * from (select rownum A, T. * From testtab t) where a = 4;
Cannot be:
Select * from (select rownum, T. * From testtab t) Where rownum = 2; or
Select * From testtab where rownum = 2;
Multiple rows of records are returned:
Select * from testtab where rownum <= 10;
Return a record segment: (for example, 4-10 rows in the record table)
Select * from (select rownum no, testtab. * from testtab where rownum <= 10) where no> = 4;
Return a qualified and sorted segment of records:
Select rownum num1, tt. * from
(Select rownum num, t. * from
(Select EcodeInfo. * from EcodeInfo where a = 1 order by ecode desc) t) tt
Where num> 19 and rownum <20>
It is assumed that Oracle extracts records before sorting, while Oracle's rownum is generated when the records are extracted, Which is prior to sorting. Therefore, subqueries must be used to sort records first.
Cannot be:
Select * from tsettab where rownum> 10;
Return the last record:
Select * from (select rownum a, t. * from testtab t) where a = (select count (*) from testtab );
Returns the last n rows of records:
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. * From sorttable a order by sortid) B)
Where row_id between 5 and 9;