sql语句

问个sql语句:
比如我表中一个字段brithday 生日字段。
我想查询要个结果就是,生日和今天 的日期比较
查询出 18岁以下,18岁-20岁,20-30岁,30-40岁,40岁以上 等等值间的人数有好多,该如何写?


------------------------这是我写的:帮忙看哈
 select sum(num) as count ,dis from (
   select count(age) as num,
          case 
            when age < 18 then '小于18岁' 
            when age >=18 and age<=25 then '18岁到25岁之间'  
            when age >=26 and age<=35 then '20岁到35岁之间' 
            when age >=36 and age<=50 then '36岁到50岁之间'
            when age >=51 and age<=60 then '51岁到60岁之间'
            when age >=61 and age<=64 then '61岁到64岁之间'
            else '65以上' 
           end dis 
       from (
           select ROUND(MONTHS_BETWEEN(SYSDATE,ZR04)/12,1) age from into_prison i
           left join criminal_now_info c on c.into_prison_id=i.id
           left join state_info si on c.state_id = si.id
           where si.register_state = '服刑'
   )group by age
 ) group by dis
 

你可能感兴趣的:(sql,C++,c,C#)