编辑代码

CREATE DATABASE test;
use test;
CREATE TABLE student (
	name varchar(255),
    score int,
    course varchar(255)
);

INSERT INTO student VALUES ('张三', 75,'语文');
INSERT INTO student VALUES ('李四', 85,'语文');
INSERT INTO student VALUES ('张三', 81,'数学');
INSERT INTO student VALUES ('李四', 77,'数学');
INSERT INTO student VALUES ('张三', 79,'化学');
INSERT INTO student VALUES ('李四', 82,'化学');

select a.course,a.score,a.name from student as a,
(select course,max(score) as maxscore from student group by course) as max_student where a.course=max_student.course and a.score=max_student.maxscore ;