查詢各科成績最高和最低的分:以如下形式顯示:課程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#


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM