sql查询最大值?
查询Score表中的最高分的学生学号和课程号。SNOCNODEGREE--------------------1033-24586.01053-24575.01093-2...
查询Score表中的最高分的学生学号和课程号。
SNO CNO DEGREE
--- ----- ------------
103 3-245 86.0
105 3-245 75.0
109 3-245 68.0
103 3-105 92.0
105 3-105 88.0
109 3-105 76.0
101 3-105 64.0
107 3-105 91.0
108 3-105 78.0
101 6-166 85.0
107 6-106 79.0
108 6-166 81.0
查询最大值select max(degree) from score ;可以查处最大分数是92.
可是题目要的是最高分的学生学号和课程号!请大侠们指点下 展开
SNO CNO DEGREE
--- ----- ------------
103 3-245 86.0
105 3-245 75.0
109 3-245 68.0
103 3-105 92.0
105 3-105 88.0
109 3-105 76.0
101 3-105 64.0
107 3-105 91.0
108 3-105 78.0
101 6-166 85.0
107 6-106 79.0
108 6-166 81.0
查询最大值select max(degree) from score ;可以查处最大分数是92.
可是题目要的是最高分的学生学号和课程号!请大侠们指点下 展开
展开全部
select SNO,CNO from Score where degree=(select max(degree) from score)
或者
select top 1 SNO,CNO from Score order by degree desc
或者
select top 1 SNO,CNO from Score order by degree desc
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select
top
1
table_b.counta
from
(select
a,
count(*)
as
counta
from
table
group
by
a)
as
table_b
order
by
table_b.counta
desc
top
1
table_b.counta
from
(select
a,
count(*)
as
counta
from
table
group
by
a)
as
table_b
order
by
table_b.counta
desc
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用如下语句可以查出各课程的最高分学号和科目号以及得分:
select sno,cno,degree from Score a where not exists
(select * from Score b where a.sno=b.sno and a.cno=b.cno and a.degree<b.degree)
select sno,cno,degree from Score a where not exists
(select * from Score b where a.sno=b.sno and a.cno=b.cno and a.degree<b.degree)
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SELECT A.SNo,A.CNo,A.Degree
FROM Score S JOIN (SELECT MAX(Degree) AS Degree FROM Score) AS T
ON S.Degree = T.Degree
FROM Score S JOIN (SELECT MAX(Degree) AS Degree FROM Score) AS T
ON S.Degree = T.Degree
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询