sql查询每门课程成绩最高的学生

给出数据库(sco)如下图:

    

查出每门课程成绩最高的学生

1 select b.id,b.kemu,b.name,b.chengji 
2 from (select kemu,max(chengji) maxc 
3     from sco group by kemu) a,sco b 
4     where a.kemu=b.kemu and a.maxc = b.chengji;

其中

select kemu,max(chengji) maxc 
from sco group by kemu

表示查出每科最高成绩和对应科目

查询出每科最高成绩之后,从所有成绩中查询对应的学生的详细信息

 

posted @ 2015-04-30 14:14  iGel  阅读(3793)  评论(0编辑  收藏  举报