MySQL与Oracle 按年龄段分组查询

2014-11-24 17:56:41 · 作者: · 浏览: 1

select nnd, count(*) from(
select
case
when em_age>=1 and em_age<=10 then '1-10'
when em_age>=11 and em_age<=20 then '11-20'
when em_age>=21 and em_age<=30 then '21-30'
when em_age>=31 and em_age<=40 then '31-40' else 'other'
end
as nnd,em_sex from hr_employee
) hr_employee group by nnd