oracle11gora-00979

ORA-00979: not a GROUP BY expression Error, how to resolve?


SELECT ssn, fname, minit, lname, AVG(hours)
FROM EMPLOYEE, WORKS_ON
WHERE EMPLOYEE.ssn = WORKS_ON.essn
GROUP BY hours
ORDER BY AVG(hours) DESC

It shows error of ORA-00979: not a GROUP BY expression

I wonder why its not working? Btw, all table exist and free of any errors. Its in Oracle AE 11g ===========UPDATE========================== The table as requested

SSN FNAME   MINIT   LNAME   AVG(HOURS)
888665555   James   E   Borg    -
666884444   Ramesh  K   Narayan 40
999887777   Alicia  J   Zelaya  20
987987987   Ahmad   V   Jabbar  20
453453453   Joyce   A   English 20
123456789   John    B   Smith   20
987654321   Jennifer    S   Wallace 17.5
333445555   Franklin    T   Wong    7.33333333333333333333333333333333333333

Solution

  • I think you're grouping by the exact opposite of what you need. You want:

    SELECT ssn, fname, minit, lname, AVG(hours)
    FROM EMPLOYEE, WORKS_ON
    WHERE EMPLOYEE.ssn = WORKS_ON.essn
    GROUP BY ssn, fname, minit, lname
    ORDER BY AVG(hours) DESC