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 -> How do I get one record from a group for a maximum value?

How do I get one record from a group for a maximum value?

From: <jonathanzta_at_yahoo.com>
Date: 25 Oct 2006 18:10:05 -0700
Message-ID: <1161825005.914430.159670@i42g2000cwa.googlegroups.com>

C1(PK)  C2        C3                C4
=====================
1           psn-a    10/10/2005    Y
3           psn-b    09/09/2009    N
5           psn-a    10/10/2006    Y

>From the table above, I want to get columns C2, C3, and C4 for records

which have the same
value for C2 and C3 is the maximum. The results should be:

3 psn-b 09/09/2000 N
5 psn-a 10/10/2006 Y

I tried various group by but wasn't able to make it work (perhaps I'm confused).
In pseudo code this would be:

Get the columns C2, C3, C4 for a particular C2 where C3 has the maximum value.

Any suggestions (along with sample SQL are really welcome)

P.S.
This is a general query and not Oracle specific. However, I didn't find a better group to post this. Received on Wed Oct 25 2006 - 20:10:05 CDT

Original text of this message

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