Google

Tuesday, February 17, 2009

Limit the number of rows in Oracle and MySql

Say we want to select 10 records for a perticular query, we can use the following syntax

// mysql 

select column from table limit 10;

// Oracle 

select column from table where rownum <= 10;

 

If we want to select number of records from the results set in Oracle,

// Oracle 

select * from (select a.*, rownum rnum from (select column from table) a where rownum <=10) where rnum >= 5;

No comments: