Search code examples
mysqlsqldatabasemysql-error-1111

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


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

Solution

  • 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
      )