56,675
社区成员
发帖
与我相关
我的任务
分享
select tb.*
from
(
select name,
max(score) as max_score,
min(score) as min_score
from tb
group name
)t
inner join tb
on tb.name = t.name and (tb.score = t.max_score or tb.score = t.min_score)
select * from (
select * from (select id,score,name from tb group by name order by score desc )
union all
select * from (select id,score,name from tb group by name order by score)
) as t
order by t.name