Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: please help with SQL query...
Unless someone comes up with a prettier solution, try this:
SELECT MessageID(PK)
FROM (SELECT OriginalMessageID, MAX(ExecDate) MAXDATE
FROM table_name GROUP BY OriginalMessageID) a, table_name bWHERE MAXDATE = b.ExecDate
Should work, even though its not so pretty...
In article <JCcp5.15372$Z2.182255_at_nnrp1.uunet.ca>,
"Massimo Di Marco" <massimo_at_sfcommerce.com> wrote:
> I need some help to figure out how to do this query...
>
> Here is the data:
>
> OriginalMessageID MessageID(PK) ExecDate
> 1 1234 10:20
> 1 5FE2 10:55
> 1 EA33 10:50
> 2 4667 11:10
> 2 98EA 10:13
>
> Now I need the MessageID for the latest record for each
OriginalMessageID,
> so the result would be:
>
> MessageID(PK)
> 5FE2
> 4667
>
> What would the SQL SELECT look like to get this result....
>
> Thanks
> Massimo
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Thu Aug 24 2000 - 13:28:43 CDT
![]() |
![]() |