Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to get the first 10 rows of a table
This gives you predictable result
select * from
(select * from table
order by primary_key_or_something_else )
where rownum<10
Norman Dunbar wrote:
> Frank,
>
> if you want the first 10 rows in the table as returned by the query
> 'select * from table' then the answer posted by Richard Z will suffice.
>
> If, on the other hand, you want the first 10 rows inserted into the
> table, in the order they were inserted, then I'm afraid you have no
> chance - unless your rows have a date & timestamp.
>
> There is an article here
> http://www.oracle.com/oramag/oracle/01-nov/index.html?o61asktom.html
> which explains why not. (It's based on getting the final row from a
> table, but the workings are identical.) Scroll down past the first two
> questions to get to the 'last row' bit.
>
> Regards,
> Norman.
>
> ------------------------------------------------------------------------
> -----
> Norman Dunbar EMail: Norman.Dunbar_at_LFS.co.uk
> Database/Unix administrator Phone: 0113 289 6265
> Fax: 0113 289 3146
> Lynx Financial Systems Ltd. URL: http://www.Lynx-FS.com
> ------------------------------------------------------------------------
> -----
>
> -----Original Message-----
> From: frank [mailto:frankw_at_qd.lucent.com]
> Posted At: Monday, April 15, 2002 9:21 AM
> Posted To: server
> Conversation: How to get the first 10 rows of a table
> Subject: How to get the first 10 rows of a table
>
> Hi,
>
> I want to know how can I get the first 10 rows of a table's data.
> (Oracle 8.1.6)
>
> Thanks in advance
> Frank
Received on Tue Apr 16 2002 - 11:41:29 CDT