昆仑资源网 Design By www.lawayou.com
1.相关数据表

Score表
sql查询出各科成绩最好的学生信息 
[User]表
sql查询出各科成绩最好的学生信息
SQL语句如下:
复制代码 代码如下:
--查询出各科成绩最好的学生信息
--自连接
--SELECT TOP 1 * FROM Score B WHERE B.ScoreName = '数学' ORDER BY B.Score DESC

SELECT A.ID,U.Name,A.ScoreName,A.Score
FROM Score A,[User]U
WHERE UID IN (SELECT TOP 1 UID
FROM Score B
WHERE B.ScoreName = A.ScoreName
ORDER BY B.Score DESC) AND A.UID=U.ID
ORDER BY A.ScoreName, A.Score DESC

查询结果如下图:
sql查询出各科成绩最好的学生信息
昆仑资源网 Design By www.lawayou.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
昆仑资源网 Design By www.lawayou.com