select t.*from ( select ,( select count(distinct score) from grade where g.job=job and g.score<=score ) t_rank from grade g) tinner join ( select job,if(count()&1,floor(count()/2)+1,convert(count()/2,SIGNED)) start,if(count()&1,floor(count()/2)+1,convert(c...