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: selecting a column according to a minimum

Re: selecting a column according to a minimum

From: Martin Dachselt <dachselt_at_firstgate.de>
Date: 20 Oct 2004 03:18:08 -0700
Message-ID: <bdafd998.0410200218.6caf0e29@posting.google.com>


"Agoston Bejo" <gusz1_at_freemail.hu> wrote in message news:<cl2m1n$tbk$1_at_news.caesar.elte.hu>...
> Actually, here is what I could come up with:
>
> select i from
> (SELECT i, j FROM T WHERE [condition] ORDER BY j )
> WHERE ROWNUM = 1
>
> Is this very inefficient?
>

According to oracle doc the rownum is computed before the "order by" statement is applied.

Perhaps better:

select i,j from
(select i,j,row_number() over (order by j) rn) where rn=1;

Bye
Martin Received on Wed Oct 20 2004 - 05:18:08 CDT

Original text of this message

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