题解 | 考试分数(五)
------一切以实现功能为主系列
select id, job, score, rk as t_rank
from
(
select id, job, score, rk, floor((cnt+1) /2) as start, ceiling((cnt+1)/2) as end
from
(
select id, job, score, row_number() over(partition by job order by score desc) as rk, count(job) over(partition by job) as cnt
from grade
) as t
) as t1
where rk=start or rk=end
order by id asc

