题解 | #考试分数(五)#
考试分数(五)
https://www.nowcoder.com/practice/b626ff9e2ad04789954c2132c74c0512
SELECT t.id,t.job,t.score,t.rw t_rank FROM ( SELECT *, ROW_NUMBER() over(PARTITION by job ORDER BY score DESC) rw FROM grade ) t JOIN ( SELECT job, FLOOR((1 + COUNT(*)) / 2) low, CEIL((1 + COUNT(*)) / 2) high FROM grade GROUP BY job ) t1 ON t.job = t1.job WHERE t.rw BETWEEN t1.low AND t1.high ORDER BY t.id;