Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: selecting a column according to a minimum
"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