with t1 as ( select job, count(score) as cnt from grade group by job ) select job, (case when MOD(cnt, 2) = 0 then round(cnt/2,0) else CEILING(cnt/2) end) as start, (case when MOD(cnt, 2) = 0 then round(cnt/2,0) + 1 else CEILING(cnt/2) end) as end from t1 order by job;