a表 id name score
1 张三 50
2 李四 60
2 王武 70
3 陈芳 80
3 李明 90
3 成五 100
查询结果
id name score
1 张三 50
2 李四 60
3 陈芳 80
1 张三 50
2 李四 60
2 王武 70
3 陈芳 80
3 李明 90
3 成五 100
查询结果
id name score
1 张三 50
2 李四 60
3 陈芳 80
from a t
where not exists(select 1 from a where id=t.id and score<t.score)
declare @a表 table (id int,name varchar(4),score int)
insert into @a表
select 1,'张三',50 union all
select 2,'李四',60 union all
select 2,'王武',70 union all
select 3,'陈芳',80 union all
select 3,'李明',90 union all
select 3,'成五',100select * from @a表 a
where score=(select min(score) from @a表 where id=a.id)
/*
id name score
----------- ---- -----------
1 张三 50
2 李四 60
3 陈芳 80
*/