select c.name , round (avg(sC.progress),1) Average_progress
from course c
join studentCourse sC on sC.courseid=c.id
group by c.name
having max avg(sC.progress)
select c.name, round(avg(sC.progress),1) Average_progress
from course c join
studentCourse sC
on sC.courseid = c.id
group by c.name
order by avg(sC.progress) desc
limit 1;
select *
from (
select c.name, round (avg(sC.progress), 1) as Average_progress
from course c
join studentCourse sC on sC.courseid = c.id
group by c.name
) x
order by Average_progress desc
limit 1
结果:
name Average_progress
--------- ----------------
Course 2 250.5
2条答案
按热度按时间ia2d9nvy1#
你只需要一个
order by
以及limit
:oyjwcjzk2#
你可以做:
结果:
参见db fiddle的运行示例。