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_at_posting.google.com>
Date: 20 Oct 2004 03:18:08 -0700
Message-ID: <bdafd998.0410200218.6caf0e29_at_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 - 12:18:08 CEST