这个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);
你可以用上面的语句试试看

如果回答对您有帮助,请采纳