方法一:
select substr(t.user_code ,7,8)
from table t
where substr(t.user_code ,7,8) < (select to_char(sysdate - interval '60' year,'yyyyMMdd') from dual)
说明:substr(t.user_code ,7,8) 截取身份证号里面的出生日期
select to_char(sysdate - interval '60' year,'yyyyMMdd') from dual --> 获取当前时间减去60年的时间
substr(t.user_code ,7,8) < (select to_char(sysdate - interval '60' year,'yyyyMMdd') from dual) --> 判断条件
---------------------
作者:水月轨迹
来源:CSDN
原文:https://blog.csdn.net/sygjzmh/article/details/45371771
版权声明:本文为博主原创文章,转载请附上博文链接!
方法二:
获取年龄在16到34岁之间的人
select count(distinct a.aac001)
from ic10a1 a,ac01 b
where a.aac001 = b.aac001
and a.aae116 <> '3' --状态
and b.aac004 = '2' --性别 男
AND (SELECT to_number('2019') - to_number(substr(b.aac002,7,4)) FROM dual) between 16 AND 34
from ic10a1 a,ac01 b
where a.aac001 = b.aac001
and a.aae116 <> '3' --状态
and b.aac004 = '2' --性别 男
AND (SELECT to_number('2019') - to_number(substr(b.aac002,7,4)) FROM dual) between 16 AND 34