题解 | #考试分数(四)#
考试分数(四)
http://www.nowcoder.com/practice/502fb6e2b1ad4e56aa2e0dd90c6edf3c
- 直接case when暴力做吧
with grade_rank as(
select job,
count(*) total
from grade group by job),
med_1 as(
select
job,
case when total%2=1 then (total+1)/2
when total%2<>1 then (total)/2 end,
case when total%2=1 then (total+1)/2
when total%2<>1 then (total)/2+1 end from grade_rank
)
SELECT * FROM MED_1