Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: SQL Query Help
I had tried this as per Oracle Metalink Note.When I add the group by ID it will display both the records like
2 1/20/2003 2:56:18 AM 1 4/23/2003 10:26:42 PM but I want to see the only the record with the latest time stamp like 1 4/23/2003 10:26:42 PM
-----Original Message-----
Sent: Wednesday, May 28, 2003 6:25 PM
To: Multiple recipients of list ORACLE-L
Add "group by ID;" as in:
SELECT ID,MAX(LastModDate) FROM Tab
group by ID;
> -----Original Message-----
> From: Basavaraja, Ravindra [mailto:Ravindra.Basavaraja_at_T-Mobile.com]
> Sent: Wednesday, May 28, 2003 8:15 PM
> To: Multiple recipients of list ORACLE-L
> Subject: SQL Query Help
>
>
> i have a query that returns 2 rows with one column being id
> and the other
> being date-time stamp.
>
> i want to select the row with the latest timestamp among those two
> records.they have difference id values
>
> SELECT ID,LastModDate
> FROM Tab
>
> ID LastModDate
> -- -----------
> 2 1/20/2003 2:56:18 AM
> 1 4/23/2003 10:26:42 PM
>
> I want to modify the above query to return the row with id=1
> which has the
> latest timestamp
>
> I tried this
>
> SELECT ID,MAX(LastModDate)
> FROM Tab
>
> getting this error
> OERR: ORA 937 not a single-group group function
>
> how do i get this work.
>
> Thanks
>
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Murray, Margaret INET: mamurray_at_husseyseating.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Basavaraja, Ravindra INET: Ravindra.Basavaraja_at_T-Mobile.com Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Wed May 28 2003 - 21:24:39 CDT