SQL 练习35

  • 查询选修「张三」老师所授课程的学生中,成绩最高的学生信息及其成绩
方式1:
SELECT Student.sid,Student.sname,t.score from Student ,
	(SELECT TOP 1 *  from sc WHERE CId = (SELECT CId from Teacher,Course WHERE Teacher.TId = Course.TId AND Tname = '张三' ) ORDER BY score DESC ) t
WHERE Student.SId = t.sid


方式2:
select top 1 student.*, sc.score, sc.cid from student, teacher, course,sc 
where teacher.tid = course.tid
and sc.sid = student.sid
and sc.cid = course.cid
and Teacher.tid = Course.TId
and teacher.tname = '张三'  ORDER BY SC.score DESC

image

posted @ 2021-08-20 19:27  弩哥++  阅读(31)  评论(0)    收藏  举报