select * from Student a where not exists(select 1 from Student where name=a.name and score>a.score)
select Name,Score=max(Score) from Student group by Name 就OK了
--如果 Studen 有多个字段,其他字段也要显示出来 select * from Studen a where not exists(select * from Studen where name=a.name and Score>a.Score) --如果 Studen 只有字段,或者只查询这两个字段 select name,Score=max(Score) from Studen group by name
聚合函数就可以完成了.
同意一楼
where not exists(select 1 from Student where name=a.name and score>a.score)
就OK了
--如果 Studen 有多个字段,其他字段也要显示出来
select * from Studen a
where not exists(select * from Studen where name=a.name and Score>a.Score)
--如果 Studen 只有字段,或者只查询这两个字段
select name,Score=max(Score)
from Studen group by name