select id,job,score,t_rank2
from
(
select *
,rank() over(partition by job order by score) t_rank1
,rank() over(partition by job order by score desc) t_rank2
,count(id) over(partition by job) s
from grade
) t
where t_rank1>=t.s/2 and t_rank2>=t.s/2
order by id 思路:可参考第88题,都是利用正序逆序都大于等于总数的一半得到中位数。

京公网安备 11010502036488号