Error Code: 1111. Invalid use of group function MYSQL ERROR

54 Views Asked by At

I´m trying to find a list of students who are below the average grade of course

I have this query

Select studentName 
from courseGrade 
where grade < avg(grade) and sectionID=290001
1

There are 1 best solutions below

0
The Impaler On BEST ANSWER

Use a subquery to compute the average grade of the course. For example:

select studentName 
from courseGrade 
where sectionID = 290001
  and grade < (
    select avg(grade) from courseGrade where sectionID = 290001
  )