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: Getting the first row using ORDER BY

Re: Getting the first row using ORDER BY

From: Godlevsky Eddy <ouvd_at_tetragr.zaporizhzhe.ua>
Date: Mon, 11 May 1998 13:47:27 GMT
Message-ID: <01bd7cdb$45b95da0$39142cc2@ouvd.tetragr.zaporizhzhe.ua>

> Oracle assigns the values of the pseudocolumn ROWNUM before it applies
> the ORDER BY clause. How would one obtain the first row of the ordered
> result set ?
>
> One solution is to declare a cursor using the ORDER BY clause. Then by
> opening
> the cursor and fetching only the first row, this row may be obtained.
> This seems
> sloppy, however.
>
> Any suggestions ?

select * from ( select .... order by...) where ROWNUM=1;

Eddy. Received on Mon May 11 1998 - 08:47:27 CDT

Original text of this message

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