SQL ORDER BY LIMIT

We can retrieve limited rows from the database. I can be used in pagination where are forced to show only limited records like 10, 50, 100 etc.

LIMIT CLAUSE FOR ORACLE SQL:

If you want to use LIMIT clause with SQL, you have to use ROWNUM queries because it is used after result are selected.

You should use the following code:

SELECT name, age  

FROM   

(SELECT name, age, ROWNUM r  

FROM   

(SELECT name, age, FROM employee_data  

ORDER BY age DESC  

)  

WHERE ROWNUM <=40  

)  

WHERE r >= 21;

This query will give you 21th to 40th rows.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *