21、查询不同老师所教不同课程平均分从高到低显示 SELECTmax(Z.T#) AS 教师ID,MAX(Z.Tname) AS 教师姓名,C.C# AS 课程ID,MAX(C.Cname) AS 课程名称,AVG(Score) AS 平均成绩 FROM SC AS T,Course AS C ,Teacher AS Z where T.C#=C.C# and C.T#=Z.T# GROUPBY C.C# ORDERBYAVG(Score) DESC 22、查询如下课程成绩第 3 名到第 6 名的学生成绩单:企业管理(001),马克思(002),UML (003),数据库(004) [学生ID],[学生姓名],企业管理,马克思,UML,数据库,平均成绩 SELECTDISTINCTtop3 SC.S# As 学生学号, Student.Sname AS 学生姓名 , T1.score AS 企业管理, T2.score AS 马克思, T3.score AS UML, T4.score AS 数据库, ISNULL(T1.score,0) +ISNULL(T2.score,0) +ISNULL(T3.score,0) +ISNULL(T4.score,0) as 总分 FROM Student,SC LEFTJOIN SC AS T1 ON SC.S# = T1.S# AND T1.C# ='001' LEFTJOIN SC AS T2 ON SC.S# = T2.S# AND T2.C# ='002' LEFTJOIN SC AS T3 ON SC.S# = T3.S# AND T3.C# ='003' LEFTJOIN SC AS T4 ON SC.S# = T4.S# AND T4.C# ='004' WHERE student.S#=SC.S# and ISNULL(T1.score,0) +ISNULL(T2.score,0) +ISNULL(T3.score,0) +ISNULL(T4.score,0) NOTIN (SELECT DISTINCT TOP15WITH TIES ISNULL(T1.score,0) +ISNULL(T2.score,0) +ISNULL(T3.score,0) +ISNULL(T4.score,0) FROM sc LEFTJOIN sc AS T1 ON sc.S# = T1.S# AND T1.C# ='k1' LEFTJOIN sc AS T2 ON sc.S# = T2.S# AND T2.C# ='k2' LEFTJOIN sc AS T3 ON sc.S# = T3.S# AND T3.C# ='k3' LEFTJOIN sc AS T4 ON sc.S# = T4.S# AND T4.C# ='k4' ORDERBYISNULL(T1.score,0) +ISNULL(T2.score,0) +ISNULL(T3.score,0) +ISNULL(T4.score,0) DESC);
23、统计列印各科成绩,各分数段人数:课程ID,课程名称,[100-85],[85-70],[70-60],[ <60] SELECT SC.C# as