select * from cj A where 成绩 = 
 (select max(成绩) from cj where 学号 = A.学号 and 课号 = A.课号)

解决方案 »

  1.   

    SELECT 学号, 课号, MAX(成绩),MAX(学期)  FROM cj GROUP BY 学号, 课号
      

  2.   

    select * from cj tem where 成绩=(select max(成绩) from cj where 学号=tem.学号 and 课号=tem.课号)
      

  3.   

    你把学期也放到group by 中就行了。
      

  4.   

    select * from cj A where not exists (select 1 from cj where 学号 = A.学号 and 课号 = A.课号 and cj>a.cj)
      

  5.   

    赞同:
    select * 
    from cj T
    where 成绩=(select max(成绩) 
                  from cj 
                 where 学号=t.学号 and 课号=t.课号)
      

  6.   

    谢谢。向各位星星学习!  :)
    To freeliu() .应该不行的
    顺便多问一句,象各位的方法,如果成绩相同学号和课号的成绩的两个学期的成绩都为50,那么通过Max(成绩),就会得到两条记录,如果我想随便得到其中的一条,怎样写语句才好?
    再谢。