欢迎来到我的博客

查询各科成绩最高和最低的分:以如下形式显示:课程ID,最高分,最低分

 SELECT L.C# As 课程ID,L.score AS 最高分,R.score AS 最低分

    FROM SC L ,SC AS R

    WHERE L.C# = R.C# and

        L.score = (SELECT MAX(IL.score)

                      FROM SC AS IL,Student AS IM

                      WHERE L.C# = IL.C# and IM.S#=IL.S#

                      GROUP BY IL.C#)

        AND

        R.Score = (SELECT MIN(IR.score)

                      FROM SC AS IR

                      WHERE R.C# = IR.C#

                  GROUP BY IR.C#

                    );

自己写的:select c# ,max(score)as 最高分 ,min(score) as 最低分 from dbo.sc  group by c#

posted @ 2018-10-06 21:01  八千轮回  阅读(9434)  评论(0编辑  收藏  举报
人生三从境界:昨夜西风凋碧树,独上高楼,望尽天涯路。 衣带渐宽终不悔,为伊消得人憔悴。 众里寻他千百度,蓦然回首,那人却在灯火阑珊处。