#本人愚解
select
job
,case
when mod(count(job),2)=1 then round(count(job)/2,0)
when mod(count(job),2)=0 then floor(count(job)/2)
end as start
, case
when mod(count(job),2)=1 then round(count(job)/2,0)
when mod(count(job),2)=0 then floor(count(job)/2)+1
else 0
end as end
from
(select
job
,score
from grade
group by 1,2) a
group by 1
order by 1;
#大神解法
SELECT job,
floor(( count(*) + 1 )/ 2 ) AS "start",
floor(( count(*) + 2 )/ 2 ) AS 'end'
FROM grade
GROUP BY job
ORDER BY job



京公网安备 11010502036488号