问题:求单科成绩最高的记录
物理模型图:
建表语句
create table score
(
id int not null,
stuid varchar(32),
subject varchar(32),
score char(10),
primary key (id)
);
初始化数据:
INSERT INTO `score` VALUES ('1', '1', '数学', '20');
INSERT INTO `score` VALUES ('2', '1', '语文', '89');
INSERT INTO `score` VALUES ('3', '1', '物理', '86');
INSERT INTO `score` VALUES ('4', '2', '数学', '90');
INSERT INTO `score` VALUES ('5', '2', '语文', '70');
INSERT INTO `score` VALUES ('6', '2', '物理', '80');
查询sql:
select * from score t where t.score=(select max(score) from score where stuid=t.stuid)group by stuid