先考虑奇偶性
考试分数(四)
http://www.nowcoder.com/questionTerminal/502fb6e2b1ad4e56aa2e0dd90c6edf3c
SELECT job, CASE WHEN count(id)%2=1 THEN (count(id)+1)/2
WHEN count(id)%2=0 THEN count(id)/2
END AS start,
CASE WHEN count(id)%2=1 THEN (count(id)+1)/2
WHEN count(id)%2=0 THEN (count(id)+2)/2
END AS END
FROM grade
GROUP BY job
ORDER BY job
依照题意有如下中位数区间
START END
奇数 (N+1)/2 (N+1)/2
偶数 N/2 (N+2)/2