I have a table that stores a list of records for ongoing maintenance tasks, as well as the date and time when they were completed. I am trying to run a subquery to pull records for every task that has the most recent date. My SQL statement:
SELECT "ENGINEERING_COMPLIANCE"."EO" AS "EO",
"ENGINEERING_COMPLIANCE"."AC" AS "AC",
"ENGINEERING_COMPLIANCE"."PN" AS "PN",
"ENGINEERING_COMPLIANCE"."PN_SN" AS "PN_SN",
"ENGINEERING_COMPLIANCE"."HOURS_RESET" AS "HOURS_RESET",
"ENGINEERING_COMPLIANCE"."MINUTES_RESET" AS "MINUTES_RESET",
"ENGINEERING_COMPLIANCE"."CYCLES_RESET" AS "CYCLES_RESET",
"ENGINEERING_COMPLIANCE"."RESET_DATE" AS "RESET_DATE",
"ENGINEERING_COMPLIANCE"."RESET_HOUR" AS "RESET_HOUR",
"ENGINEERING_COMPLIANCE"."RESET_MINUTE" AS "RESET_MINUTE",
MAX ( "ENGINEERING_COMPLIANCE"."RESET_DATE" ) AS "LAST_COMP_DATE"
FROM ENGINEERING_COMPLIANCE
GROUP BY ( "ENGINEERING_COMPLIANCE"."EO" ) ,
( "ENGINEERING_COMPLIANCE"."AC" ) ,
( "ENGINEERING_COMPLIANCE"."PN" ) ,
( "ENGINEERING_COMPLIANCE"."PN_SN" )
However, I keep getting the following error: "ORA-00979: not a GROUP BY clause"
When I delete "GROUP BY", I get: "ORA-00937: not a group group function"
1 - what exactly does this mean 2 - what is wrong with the expression?
source
share