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

Home -> Community -> Usenet -> c.d.o.server -> Re: ORDER BY + ROWNUM error

Re: ORDER BY + ROWNUM error

From: Andreas Necker <Andreas.Necker_at_isb-ag.de>
Date: Thu, 28 Jun 2001 13:16:52 +0200
Message-ID: <3B3B1224.6996792B@isb-ag.de>

hi,

Erwin Dondorp wrote:
>
> Dino,
>
> The ORDER BY clause is executed AFTER the ROWNUMs are assigned.
> This means that the ROWNUMs are assigned more or less at random,
> but certainly not on a way that is related to the ORDER BY clause.
>
> The alternative is to open a cursor and to fetch only the first
> 3 records.
>
> Erwin
>

or try this

select empno, sal
  from ( select empno, sal

           from emp
          order by sal desc )

 where rownum < 4;

ciao
andreas Received on Thu Jun 28 2001 - 06:16:52 CDT

Original text of this message

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