select id,job,score,t_rank from ( select id,job,score, count(*)over(partition by job) total, -- 统计每个job条数 dense_rank()over(partition by job order by score desc) t_rank -- job分区,分数降序排名 from grade )t where total%2<>0 and t_rank=round(total/2) or -- job条数为奇数的情况 ...