牛客SQL练习-75-考试分数(四)
程序员文章站
2022-06-07 13:06:53
...
SELECT
job,
CASE
WHEN total % 2 = 0 THEN
total / 2 ELSE ( total + 1 )/ 2
END AS `start`,
CASE
WHEN total % 2 = 0 THEN
total / 2+1 ELSE ( total + 1 )/ 2
END AS `end`
FROM
( SELECT job, COUNT( 1 ) AS total FROM grade GROUP BY job ) t
ORDER BY
job