知识点

  1. 首先按照岗位进行分组
  2. 然后进行计数,奇数如3除以2四舍五入就是2,3加1除以2也是2符合。偶数如4中位数就是2到3之间,按之前方法计算也符合

代码

select g.job, 
round(count(g.id)/2) as start, 
round((count(g.id)+1)/2) as end
from grade g
group by g.job
order by g.job