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

本文来自博客园,作者:弩哥++,转载请注明原文链接:https://www.cnblogs.com/bangbangzoutianya/p/15167937.html
                    
                
                
            
        
浙公网安备 33010602011771号