问题描述
- 这个sql语句怎么写啊?找出每个同学最高分,最低分及对应的科目
-
select name,course as mincourse,score as minscore from userscore ore in(select min(score) from userscore group by name) group by name;
select name,course as mincourse,score as minscore from userscore ore in(select min(score) from userscore group by name) group by name;
怎么用一条语句写啊?
解决方案
光分数相当还是不够的,如果甲分数99,90,80,乙分数90,80,70,你的结果就是错的。应该同时分数相等,人一致才行
select name,course as mincourse,minscore from userscore u,
(select name,min(score) minscore from userscore group by name) mu
where u.name = mu.name and u.score=mu.score
解决方案二:
那你最好在设计表的时候设计成
学号 课程id 分数
这样比较好统计
解决方案三:
select * from table where g=max(g) or g=min(g);
你可以用上面的语句试试看
如果回答对您有帮助,请采纳
时间: 2024-09-22 16:39:14