题解 | #考试分数(四)#
考试分数(四)
http://www.nowcoder.com/practice/502fb6e2b1ad4e56aa2e0dd90c6edf3c
select job,case cnt%2 when 0 then left(cnt/2,1) else round(cnt/2) end start,
case cnt%2 when 0 then left(cnt/2+1,1) else round(cnt/2) end end
from(
select *,count(*)over(partition by job) cnt,
rank()over(partition by job order by score) rk
from grade
) hh
group by job
order by job
case cnt%2 when 0 then left(cnt/2+1,1) else round(cnt/2) end end
from(
select *,count(*)over(partition by job) cnt,
rank()over(partition by job order by score) rk
from grade
) hh
group by job
order by job