用到了MOD函数和case when循环,第一遍写又忘了加END
SELECT job ,ROUND(CASE MOD(COUNT(score),2) WHEN 1 THEN COUNT(score)/2+0.5 ELSE COUNT(score)/2 end,0) ,ROUND(CASE MOD(COUNT(score),2) WHEN 1 THEN COUNT(score)/2+0.5 ELSE COUNT(score)/2+1 end,0) FROM grade GROUP BY job order BY job