SELECT
count(*) as count,
t.age
FROM
(
SELECT
CASE
WHEN age IS NULL THEN '未知'
WHEN age <= 25 THEN '25岁以下'
WHEN age <= 30 AND age >= 26 THEN '26-30'
WHEN age <= 35 AND age >= 31 THEN '31-35'
WHEN age <= 40 AND age >= 36 THEN '36-40'
WHEN age <= 45 AND age >= 41 THEN '41-45'
WHEN age <= 50 AND age >= 46 THEN '46-50'
WHEN age >= 50 THEN '50以上'
END AS age
FROM
`cscp_emp_info`
where if_delete = 0
) as t
GROUP BY
t.age
结果: