with t as (
select job, count(1) as cnt
from grade
group by job
)
select job,
case when mod(cnt, 2)=1 then ceil(cnt/2)
when mod(cnt, 2)=0 then cast(cnt/2 as signed) end as start,
case when mod(cnt, 2)=1 then ceil(cnt/2)
when mod(cnt, 2)=0 then cast(cnt/2 as signed)+1 end as end
from t
order by job

京公网安备 11010502036488号