分享

根据出生日期按年龄段统计

 cyx_188 2017-03-10
 select nnd as age ,count(*) as num from
(
 select
 case
  when to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy') >= '0' and to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy') <= '10' then '10岁以下'
  when to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy') >= '11' and to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy')<='20' then '11-20'
  when to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy') >= '21' and to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy')<='30' then '21-30'
  when to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy') >= '31' and to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy')<='40' then '31-40'
  when to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy') >= '41' and to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy')<='50' then '41-50'
  when to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy') >= '51' and to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy')<='60' then '51-60'
  when to_char(sysdate,'yyyy')-to_char(REC_USER_BIRTHDAY,'yyyy') >'60'  then '60以上'
 end
 as nnd,REC_USER_NAME from QEFOA_RECORD
)
a
group by nnd 

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约