Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Help: Limiting the number of rows returned.
I need limit the number of rows returned on a query, the table could hold
millions of rows so we definetly do NOT want to return the entire table.
The catch is, I need to select the last n records that were modified.
When I use rownum, it doesn't order the records properly. That is, if I issue a select using rownum, ordering by a date field, it does not get the last rows. It retrieves them and then does the order by. I need it to do the order by first.
ex: SQL> select ncsn,ncnumber,date_modified from nonconform where rownum <
20 and date_modified is not
null order by date_modified desc;
Is there a way to do a select so that I will always get the correct rows? So that it orders the records, then retrieves the number of rows that I specify?
Oh yes, we're using Oracle 7.3.
Thanks,
Rich W.
Received on Tue Sep 29 1998 - 08:43:13 CDT