select 学生编号,姓名,课程编号,count(课程编号) 选课数,avg(成绩) 平均成绩 from 选课表 a join 学生表 b on a.学生编号=b.学生编号 group by 学生编号,姓名,课程编号 having count(课程编号)>5 order by avg(成绩) desc;
select count(sm.majnum) as course ,s.stunum ,round(sum(sm.majrecord)/count(sm.majnum),2) as avgrecord from student s,selectmajor sm where s.stunum=sm.stunum group by s.stunum having count(sm.majnum)>=3 order by avgrecord desc
2。对上面的结果,左连接学生,得到名字。
from 选课表 a join 学生表 b on a.学生编号=b.学生编号
group by 学生编号,姓名,课程编号
having count(课程编号)>5
order by avg(成绩) desc;
from student s,selectmajor sm
where s.stunum=sm.stunum
group by s.stunum
having count(sm.majnum)>=3
order by avgrecord desc
谢谢二位,根据你们写的,我最后写出正确的答案,可以实现。
不知道还有没有别的方法,更高效简炼一些,谢谢。