方法一: case when
中位数位置的计算:按分数升序排序,偶数个时,中位数的位置为(总个数/2)位和((总个数+1)/2)位;奇数个时,中位数的位置为(总个数+1)/2
select job ,round((case when count(score)%2=0 then count(score)/2 else (count(score)+1)/2 end),0) as start, round((case when count(score)%2=0 then count(score)/2+1 else (count(score)+1)/2 end),0) as end from grade group by job order by job;
方法二 ceil() 向上取整函数
select job ,ceil((count(score))/2) as start, ceil((count(score)+1)/2) as end from grade group by job order by job;