if函数的输出参数可以是表达式 select id,t1.job,score,t_rank from (select id,job,score,dense_rank()over(partition by job order by score desc)t_rank from grade)t1 join (select job,count(id) m from grade group by job)t2 on t1.job=t2.job and if(t2.m%2=1,t_rank=(t2.m+1)/2,t_rank in (t2.m/2,t2.m/2+1)) order by id 也可...