select * from stu,(select course,MAX(mark) as maxscore from stu group by course) temp where stu.mark = temp.maxscore and stu.course= temp.course
SELECT id,name,MAX(mark),course FROM stu ORDER BY course
应该是group by ,sql语句为: SELECT id,name,MAX(mark),course FROM stu GROUP BY course
select s.* from stu s left join (select max(mark) m,course from stu GROUP BY course) c on s.mark=c.m and s.course=c.course where c.m is not null