直接
select max(score) from table where coursename = @Course
这个有什么问题么?

解决方案 »

  1.   

    AND SC.SCORE=(SELECT MAX(SCORE) FROM T_SCORE WHERE SC.COURSENO=CO..COURSENO)
      

  2.   


    select top 1 sc.Score,stu.StudentName,co.CourseName
     from T_Score sc
     inner join T_Student stu on sc.StudentNo=stu.StudentNo 
     inner join T_Course co on sc.CourseNo=co.CourseNo
     where co.CourseName=@Course
     order by sc.Score desc
      

  3.   

    提问学习
    【SQL Server版块】提问的智慧
    http://bbs.csdn.net/topics/391996442
    代码贴图的同时把语句贴出来,这样方便大家直接COPY来更改你的BUG
      

  4.   

    CREATE PROCEDURE [dbo].[GetMaxScore]
    @Course nvarchar(100)
    as
    begin
    select  sc.Score,stu.StudentName,co.CourseName  
    from  T_Score as sc
    join T_Student as stu on sc.StudentNo = stu.StudentNo
    left join T_Course as co  on sc.CourseNo = co.CourseNo 
    where co.CourseName=@Course and sc.Score=(select max(Score) from T_SCORE where sc.CourseNo=co.CourseNo)
    end
    GOexec GetMaxScore'语文'这样吗
      

  5.   


    SELECT  sc.Score ,
            stu.StudentName ,
            co.CourseName
    FROM    T_Score sc
            INNER JOIN T_Student stu ON sc.StudentNo = stu.StudentNo
            INNER JOIN T_Course co ON sc.CourseNo = co.CourseNo
    WHERE   co.CourseName = @Course
            AND sc.Score = ( SELECT MAX(Score)
                             FROM   T_Score
                             WHERE  CourseNo = sc.CourseNo
                           );--加上CourseNo按课程取最高分
     
      

  6.   

    CREATE PROCEDURE [dbo].[GetMaxScore]
    @Course nvarchar(100)
    as
    begin
    select  sc.Score,stu.StudentName,co.CourseName  
    from  T_Score as sc
    join T_Student as stu on sc.StudentNo = stu.StudentNo
    left join T_Course as co  on sc.CourseNo = co.CourseNo 
    where co.CourseName=@Course and sc.Score=(select max(Score) from T_SCORE where CourseNo=sc.CourseNo)
    end
    GOexec GetMaxScore'语文'
    好像就是多了一个CO