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: select rows matching a condition in each group

Re: select rows matching a condition in each group

From: Erik <no_at_spam.com>
Date: Tue, 6 Jan 2004 20:04:17 +0100
Message-ID: <btf0tr$l1n$1@news.lth.se>


"June-young Jang" <flips_at_hanmail.net> wrote in message news:cbfa2ee1.0312260007.40365113_at_posting.google.com...
> Hello..
> I need a *simple* and *efficient* SQL query like this.
> (I am working on Oracle 9i)
>
> Example) Table T.
>
> CA CB CC CD
> --- --- --- ---
> 1 G1 10 A
> 2 G2 20 Q
> 3 G1 50 Z
> 4 G1 45 T
> 5 G2 90 H
> 6 G3 90 P
>
> Result that I want)
>
> CA CB CC CD
> --- --- --- ---
> 1 G1 10 A
> 2 G2 20 Q
> 6 G3 90 P

I don't know whether it is more or less efficient than the other suggestions, but I have previously done: SELECT t.ca, t.cb, t.cc, t.cd

    FROM t, (SELECT cb, MIN(cc) FROM t GROUP BY cb) a     WHERE a.cb = t.cb AND a.cc = t.cc Received on Tue Jan 06 2004 - 13:04:17 CST

Original text of this message

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