select p.*
from
(
select 课程,系别,count(修课.学号) as b from 学生 inner join 修课 on 学生.学号=修课.学号
group by 课程,系别
) as p
inner join
(
select 课程,max(b) as b from
(
select 课程,系别,count(修课.学号) as b from 学生 inner join 修课 on 学生.学号=修课.学号
group by 课程,系别
) as c group by 课程
) as c
on p.课程=c.课程 and p.b=c.b
select 课程,系别,max(xx_rs) from (
select b.课程,a.系别,count(a.学号) xx_rs from 学生 a,修课 b
where a.学号=b.学号
group by b.课程,a.系别)
group by 课程,系别;