Oracle如何实现按身份证号得到省市、性别、年龄
发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,小编这次要给大家分享的是Oracle如何实现按身份证号得到省市、性别、年龄,文章内容丰富,感兴趣的小伙伴可以来了解一下,希望大家阅读完这篇文章之后能够有所收获。1、通过身份证号查询所在省市SELECT
千家信息网最后更新 2026年11月02日Oracle如何实现按身份证号得到省市、性别、年龄
小编这次要给大家分享的是Oracle如何实现按身份证号得到省市、性别、年龄,文章内容丰富,感兴趣的小伙伴可以来了解一下,希望大家阅读完这篇文章之后能够有所收获。
1、通过身份证号查询所在省市
SELECTcount(*) as total, case substr(t.CERTNO,0,2) when '11' then '北京市' when '12' then '天津市' when '13' then '河北省' when '14' then '山西省' when '15' then '内蒙古自治区' when '21' then '辽宁省' when '22' then '吉林省' when '23' then '黑龙江省' when '31' then '上海市' when '32' then '江苏省' when '33' then '浙江省' when '34' then '安徽省' when '35' then '福建省' when '36' then '江西省' when '37' then '山东省' when '41' then '河南省' when '42' then '湖北省' when '43' then '湖南省' when '44' then '广东省' when '45' then '广西壮族自治区' when '46' then '海南省' when '50' then '重庆市' when '51' then '四川省' when '52' then '贵州省' when '53' then '云南省' when '54' then '西藏自治区' when '61' then '陕西省' when '62' then '甘肃省' when '63' then '青海省' when '64' then '宁夏回族自治区' when '65' then '新疆维吾尔自治区' when '71' then '台湾省' when '81' then '香港特别行政区' when '82' then '澳门特别行政区' else '未知' end AS province FROM uip_bjt_userinfo t group by case substr(t.CERTNO,0,2) when '11' then '北京市' when '12' then '天津市' when '13' then '河北省' when '14' then '山西省' when '15' then '内蒙古自治区' when '21' then '辽宁省' when '22' then '吉林省' when '23' then '黑龙江省' when '31' then '上海市' when '32' then '江苏省' when '33' then '浙江省' when '34' then '安徽省' when '35' then '福建省' when '36' then '江西省' when '37' then '山东省' when '41' then '河南省' when '42' then '湖北省' when '43' then '湖南省' when '44' then '广东省' when '45' then '广西壮族自治区' when '46' then '海南省' when '50' then '重庆市' when '51' then '四川省' when '52' then '贵州省' when '53' then '云南省' when '54' then '西藏自治区' when '61' then '陕西省' when '62' then '甘肃省' when '63' then '青海省' when '64' then '宁夏回族自治区' when '65' then '新疆维吾尔自治区' when '71' then '台湾省' when '81' then '香港特别行政区' when '82' then '澳门特别行政区' else '未知'end order by province desc
2、通过身份证号得到性别(第17位为奇数为男,偶数为女)
select decode(mod(to_number(substr(t.useridcardnum, 17, 1)), 2),0,'女','男') as sex from uip_ca_userinfo t
3、通过身份证号得到年龄
select to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) as age from uip_ca_userinfo t
4、通过身份证号统计所在年龄段的人数
select count(t.id), case when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 1 and 20 then '1-20岁' when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 21 and 30 then '21-30岁' when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 31 and 40 then '31-40岁' when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 41 and 50 then '41-50岁' else '50岁以上' end as 年龄段 from uip_ca_userinfo t group by case when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 1 and 20 then '1-20岁' when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 21 and 30 then '21-30岁' when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 31 and 40 then '31-40岁' when to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 41 and 50 then '41-50岁' else '50岁以上' end order by 年龄段 asc
5、通过身份证号统计男女数量
select count(t.id), decode(mod(to_number(substr(t.useridcardnum, 17, 1)), 2),0,'女','男') as sex from uip_ca_userinfo t where to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) between 1 and 26 group by decode(mod(to_number(substr(t.useridcardnum, 17, 1)), 2),0,'女','男')
看完这篇关于Oracle如何实现按身份证号得到省市、性别、年龄的文章,如果觉得文章内容写得不错的话,可以把它分享出去给更多人看到。
自治区
证号
身份
年龄
行政区
省市
年龄段
黑龙
上海市
云南省
内蒙
内蒙古自治区
台湾省
吉林省
四川省
天津市
宁夏
宁夏回族自治区
安徽省
山东省
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
互联网黑科技
广州为想互联网科技有限公司
上海挚品互联网科技
卓越科技(互联网 )
银优互联网科技有限公司
郑州华宇互联网科技
互联网前沿科技
成都狮子座互联网科技
现代科技和互联网有关系吗
昊天互联网科技有限公司
赶超互联网科技 微信多开
玉溪互联网科技怎么选
佛山市翊博互联网络科技有限公司
长沙互联网科技
互联网营销推广黑科技
互联网科技企业商标注意事项
兰石爱特工业互联网科技分公司
科技信息时代互联网发展
互联网时代高科技布局
互联网科技创业计划的风险分析
百单网互联网科技有限公司
互联网最新的科技有限公司
碳银互联网科技
深圳卡尔迅互联网科技有限公司怎么样
滨湖区互联网智能科技产品供应
互联网校园科技培训
银行科技岗属于互联网吗
上海同邻互联网科技有限公司规模
互联网高科技绘画
如何强化互联网金融科技