我在MySQL中遇到了以下问题的问题
问题出现在别名'T'
select course_id, sec_id, enrollment
from (
select course_id, sec_id, count(ID) as enrollment
from section natural join takes
where semester = 'Fall' and year =2009
group by course_id, sec_id
) as T
where enrollment = (select max(enrollment) from T);
答案 0 :(得分:0)
如果你没有任何吸引力,我想你可能会得到类似下面的内容。
select course_id, sec_id, count(*) as enrollment
from section s
join takes t on s.sec_id = t.course_id
where semester = 'Fall' and year =2009
group by course_id, sec_id
order by count(*) desc
limit 1
;