--输出每门功课成绩最好的学生数据,表名为 stu。mysql不是oracle

https://img3.mukewang.com/5cdd2ac00001e68d05770173.jpg

炎炎设计
浏览 737回答 5
5回答

慕村225694

select * from stu,(select course,MAX(mark) as maxscore from stu group by course) temp where stu.mark = temp.maxscore and stu.course= temp.course

饮歌长啸

这样好些,select id,name,stu.mark,stu.course from stu,( select course,MAX(mark) as maxscore from stu group by course) temp where stu.mark = temp.maxscore and stu.course= temp.course

慕侠2389804

SELECT id,name,MAX(mark),course FROM stu ORDER BY course

明月笑刀无情

应该是group by ,sql语句为: SELECT id,name,MAX(mark),course FROM stu GROUP BY course

浮云间

select s.* from stu s left join (select max(mark) m,course from stu GROUP BY course) c on s.mark=c.m and s.course=c.course where c.m is not null
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java