Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: SQL Query Help
This will work.But the actual query that I have is a join b/w two tables
and not as simple as it looks in the example I had given
SELECT ID,LastModDate
FROM Tab
I bascially will have to include my complete main query in the sub query with TRUNC(MAX........ This might be costly on the performance.
do we have any other approach.
thanks
-----Original Message-----
[mailto:Reginald.W.Bailey_at_jpmorgan.com]
Sent: Wednesday, May 28, 2003 7:08 PM
To: Multiple recipients of list ORACLE-L
RB:
Try :
SELECT ID, LastModDate
FROM Tab a
WHERE TRUNC(LastModDate) = (Select MAX(TRUNC(LastModDate)) From Tab b)
The explanation of the error message follows.
RWB
|-----------------------------------+-----------------------------------> | | | |-----------------------------------+-----------------------------------> >-------------------------------------------------------------------------------|
|Error: ORA 937 |
| |
| |
|Text: not a single-group group function |
| |
| |
|-------------------------------------------------------------------------------|
| |
| |
|Cause: A SELECT list cannot include both a group function, such as AVG, COUNT,|
| |
| |
| MAX, MIN, SUM, STDDEV, or VARIANCE, and an individual column |
| |
| |
| expression, unless the individual column expression is included in a |
| |
| |
| GROUP BY clause. |
| |
| |
|Action: Drop either the group function or the individual column expression |
| |
| |
| from the SELECT list or add a GROUP BY clause that includes all |
| |
| |
| individual column expressions listed. |
| |
| |
|. |
>-------------------------------------------------------------------------------| ============================================================================================================
Reginald W. Bailey
IBM Global Services - ETS SW GDSD - Database Management
Your Friendly Neighborhood DBA
713-216-7703 (Office) 281-798-5474 (Mobile) 713-415-5410 (Pager)
Ravindra.Basavaraja_at_T- Mobile.com To: ORACLE-L_at_fatcity.com Sent by: cc: root_at_fatcity.com Subject: SQL Query Help 05/28/2003 07:14 PM Please respond to ORACLE-L
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: 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). -- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: INET: Reginald.W.Bailey_at_jpmorgan.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:49:39 CDT