Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.tools -> Re: select first x rows from a query

Re: select first x rows from a query

From: Marion <dont_use13_at_hotmail.com>
Date: 2000/06/09
Message-ID: <8hridr$fg2$1@nnrp1.deja.com>#1/1

Try:

SELECT * FROM
   (SELECT col1
     FROM mytable ORDER BY col3 DESC)
WHERE ROWID<4;

This requires a full table scan, so it may be slower than other options if the table is very large.

MarionB

In article <3940E4F8.E71B965_at_fh-coburg.de>,   schelhor_at_fh-coburg.de wrote:
> Hi everybody!
>
> I've a table with several rows. Then I've to run a query like:
>
> SELECT col1 FROM mytable ORDER BY col3 DESC;
>
> But now I need only the first 3 rows of that resultset. Is there a way
> to do this in
> a SQL-Statement (I know: I could do that using a FOR-loop in a
> procedure, but
> this will cause some other problems ...)
>
> thanx in advance
> Tom
>
>

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Fri Jun 09 2000 - 00:00:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US