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

Home -> Community -> Usenet -> c.d.o.misc -> Re: LIMIT number of selected rows

Re: LIMIT number of selected rows

From: Bricklen <bricklen-rem_at_yahoo.comz>
Date: Wed, 21 Jan 2004 17:18:34 GMT
Message-ID: <KvyPb.39448$Eq.22236@clgrps12>


Georg Maaß wrote:

> Hi,
>
> what is the Oracle SQL syntax to limit the number of rows returned by a
> select.
>
> MS-SQL supports TOP to do this:
>
> select TOP 1 * from stuff;
>
> But what is the correct syntax for Oracle to get only the first entry?
>
> Greetings, Georg
>

Are you looking for any row returned, as long as it's the first one, or are you looking for the top row (by whatever your criteria) from a sorted list?

select * from stuff where rownum = 1;

select * from

   (select * from stuff order by some_criteria desc) where rownum = 1;

Other ways to do this as well. Received on Wed Jan 21 2004 - 11:18:34 CST

Original text of this message

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