题解 | #考试分数(四)#
考试分数(四)
http://www.nowcoder.com/practice/502fb6e2b1ad4e56aa2e0dd90c6edf3c
select
a.job
,case when mod(max(a.r),2) = 0 then ceiling(max(a.r)/2) else ceiling(max(a.r)/2) end
,case when mod(max(a.r),2) = 0 then ceiling(max(a.r)/2+1) else ceiling(max(a.r)/2) end
from (
select
g.*
,row_number() over(partition by g.job order by score) r
from grade g
) a
group by a.job
order by a.job