Home > Enterprise >  SQL Query not working ORA-00979: not a GROUP BY expression
SQL Query not working ORA-00979: not a GROUP BY expression

Time:01-06

So I was reviewing past Exam papers and there was this question I've been trying to solve. It basically requires me to print out text in a certain "template", much like the output I've attempted. Now, this code will mostly work but will break once I try to add the Group function.

SELECT firstname, lecturerID, COUNT(ModuleCode)
from Lecturer
LEFT OUTER JOIN ModuleDelivery 
ON lecturerID = lecturerNo
GROUP BY lecturerID;

edit: I've simplified the code to avoid confusion

any clues as to what might be going wrong?

CodePudding user response:

You need to add firstname to your GROUP BY

GROUP BY firstname, lecturerID

You use an aggregate function (COUNT) on ModuleCode, so any remaining columns must either be aggregate functions (SUM/COUNT/MIN/MAX) or included in group by

(Is this a homework question?)

  •  Tags:  
  • Related