select t1.id,t1.job,t1.score,t1.rk from (select id,job,score,row_number() over (partition by job order by score desc) rk from grade ) t1 inner join (select job , ceil(count(score)/2) as start , if(count(score)%2=0,ceil(count(score)/2)+1,ceil(count(score)/2)) as end from grade group ...