select id,number,(select count(DISTINCT number)+1 from passing_number p2
where p1.number<p2.number) t_rank
from passing_number p1
order by t_rank,id

本题利用子查询生成排名,首先利用P1表number<P2表number以及count+ distinct得到每个number的排名情况,然后根据rank和id进行排序即可