查询每门课成绩最高分的同学的sql语句,输出课程名,姓名,学号,分数。表的结构如下。写出完整的sql语句
4个回答
展开全部
首先三表连接,然后select max(分数),姓名,学号, 课程 from 连接表 group by 姓名,学号, 课程
即可。
即可。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SELECT cname,sname,student.sno,grade
FROM student join sc on student.sno=sc.sno
join course on course.cno=sc.cno
where grade=(select max(grade)
from sc
where cno=course.cno )
FROM student join sc on student.sno=sc.sno
join course on course.cno=sc.cno
where grade=(select max(grade)
from sc
where cno=course.cno )
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select cname,sname,student.sno,sc1.grade
from student join SC as sc1 on student.sno=sc1.sno
join course on sc1.cno=course.cno
where not exists(
select * from SC as sc2
where sc1.cno=sc2.cno and sc1.grade<sc2.grade)and grade is not null
order by sc1.cno
from student join SC as sc1 on student.sno=sc1.sno
join course on sc1.cno=course.cno
where not exists(
select * from SC as sc2
where sc1.cno=sc2.cno and sc1.grade<sc2.grade)and grade is not null
order by sc1.cno
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询