Finding the course with worst GPA in MySQL ... Where did my query go wrong?

36 views Asked by At
Select title, credits, courseid, avg(grade) as AVG_Grade 
From Course join Exam on course.courseid= exam.cid
group by title, credits, courseid
having avg(grade) = (select min(avg(grade)) from exam); 

This is my query to find the course with the worst GPA, I would like to do it with a nested query however this doesn't seem to work.

1

There are 1 answers

0
P.Salmon On

As the error message tells you you cannot select min(avg(grade)) from exam but you can select avg(grade) gd from exam order by gd limit 1