思路:我们先来了解一下取整的几个函数

  1. ceil() / ceiling() 向上取整;示例: ceil(1.2) = 2

  2. floor() 向下取整;示例: floor(1.2) = 1

  3. round() 四舍五入

法一:使用round解决:

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

法二:使用floor+ceiling:

select job, floor((count(job) + 1)/2) as start, ceiling((count(job) + 1)/2) as end
from grade
group by job
order by job