SELECT
nld AS '年龄段',
count( * ) AS '人数',
CONVERT(nld,SIGNED) as '排序'
FROM
(
SELECT
CASE
WHEN
birthday is NULL THEN
'未知'
WHEN
birthday>'1961-10-13' THEN
'59岁以下'
WHEN birthday>'1956-10-13' AND birthday<='1961-10-13' THEN
'60-64岁'
WHEN birthday>'1951-10-13' AND birthday<='1956-10-13' THEN
'65-69岁'
WHEN birthday>'1946-10-13' AND birthday<='1951-10-13' THEN
'70-74岁'
WHEN birthday>'1941-10-13' AND birthday<='1946-10-13' THEN
'75-79岁'
WHEN birthday>'1931-10-13' AND birthday<='1941-10-13' THEN
'80-89岁'
WHEN birthday>'1921-10-13' AND birthday<='1931-10-13' THEN
'90-99岁'
WHEN birthday <='1921-10-13' THEN
'100岁以上'
END AS nld
FROM
lp_students
where juzhu_code LIKE '450503%' and fw_status=2
) a
GROUP BY
nld