select name,count(1)from (
select birthday,(case when birthday between '1940' and '1949' then '40后'
when birthday between '1950' and '1959' then '50后'
when birthday between '1960' and '1969' then '60后'
when birthday between '1970' and '1979' then '70后'
when birthday between '1980' and '1989' then '80后'
when birthday between '1990' and '1999' then '90后'
else '00后'
end) name from (
select SUBSTRING(id_number,7,4) AS birthday from v_app_queue_sq
where
id_number<>'' AND id_number IS NOT NULL AND LENGTH(id_number)=18
) m) b group by name
相关文章: