解法一:先做一个开窗的(只要知道开窗的伙伴应该都会做)解法二:后面再做个不开窗的,用mysql老版本的朋友应该都熟悉变量这种方式, select * from ( select c.tag,c.uid,row_number() over(partition by c.tag order by c.max desc,c.min desc,c.uid desc) as rk from ( select a.uid,b.tag,max(score) as max,min(score) as min from ...