提取内容:birthday,age,sex,property(属性),constellation(星座),province,age_group,six_idcard,census_register

 insert into test008select cvb4.name,cvb4.mobile,cvb4.idcard,cvb4.birthday,cvb4.age,cvb4.sex,cvb4.property,cvb4.constellation,cvb4.province,cvb4.hj,cvb4.create_date   from  (select name,mobile,idcard,create_date, case when length(idcard) = 18 then  concat_ws('-',substr(idcard,7,4),substr(idcard,11,2),substr(idcard,13,2)) when length(idcard) = 15 then concat('19',substr(idcard,7,2),'-', substr(idcard,9,2),'-', substr(idcard,11,2)) else null end  as birthday,
case when length(idcard) = 18 thenfloor(datediff( from_unixtime(unix_timestamp(),'%Y-%m-%d'), concat_ws('-',substr(idcard,7,4),substr(idcard,11,2),substr(idcard,13,2)) )/365 )when length(idcard) = 15 then floor(datediff( from_unixtime(unix_timestamp(),'%Y-%m-%d'),concat('19',substr(idcard,7,2),'-', substr(idcard,9,2),'-', substr(idcard,11,2)) )/365 ) else null end  as age,case when length(idcard) = 18 thencase when substr(idcard,17,1)%2 = 0 then '女' when substr(idcard,17,1)%2 <> 0 then '男'else null endwhen length(idcard) = 15 then case when substr(idcard,15)%2 = 0 then '女' when substr(idcard,15)%2 <> 0 then '男'else null end else null end  as sex,case when length(idcard) = 18 then case when substr(idcard,11,2)=01 then '鼠' when substr(idcard,11,2)=02 then '牛' when substr(idcard,11,2)=03 then '虎' when substr(idcard,11,2)=04 then '兔' when substr(idcard,11,2)=05 then '龙' when substr(idcard,11,2)=06 then '蛇' when substr(idcard,11,2)=07 then '马' when substr(idcard,11,2)=08 then '羊' when substr(idcard,11,2)=09 then '猴' when substr(idcard,11,2)=10 then '鸡' when substr(idcard,11,2)=11 then '狗' when substr(idcard,11,2)=12 then '猪' else null end else null end as property,case when length(idcard) = 18 then case when substr(idcard,12,3)>=312 and substr(idcard,12,3)<=419 then '白羊座'when substr(idcard,12,3)>=420 and substr(idcard,12,3)<=520 then '金牛座'when substr(idcard,12,3)>=521 and substr(idcard,12,3)<=621 then '双子座'when substr(idcard,12,3)>=622 and substr(idcard,12,3)<=722 then '巨蟹座'when substr(idcard,12,3)>=723 and substr(idcard,12,3)<=822 then '狮子座'when substr(idcard,12,3)>=823 and substr(idcard,12,3)<=922 then '处女座'when substr(idcard,12,3)>=923 and substr(idcard,12,3)<=930 then '天枰座'when substr(idcard,11,4)>=1001 and substr(idcard,11,4)<=1023 then '天枰座'when substr(idcard,11,4)>=1024 and substr(idcard,11,4)<=1121 then '天蝎座'when substr(idcard,11,4)>=1122 and substr(idcard,11,4)<=1221 then '射手座'when substr(idcard,11,4)>=1222 and substr(idcard,11,4)<=1231 then '魔蝎座'when substr(idcard,12,3)>=101 and substr(idcard,12,3)<=119 then '魔蝎座'when substr(idcard,12,3)>=120 and substr(idcard,12,3)<=218 then '水瓶座'when substr(idcard,12,3)>=219 and substr(idcard,12,3)<320 then '双鱼座'
else null end
else null end as  constellation,        case when length(idcard) = 18 thencase when substr(idcard,1,2)=11 then '北京' when substr(idcard,1,2)=12 then '天津'when substr(idcard,1,2)=13 then '河北'when substr(idcard,1,2)=14 then '山西'when substr(idcard,1,2)=15 then '内蒙古'when substr(idcard,1,2)=21 then '辽宁'when substr(idcard,1,2)=22 then '吉林'when substr(idcard,1,2)=23 then '黑龙江'when substr(idcard,1,2)=31 then '上海'when substr(idcard,1,2)=32 then '江苏'when substr(idcard,1,2)=33 then '浙江'when substr(idcard,1,2)=34 then '安徽'when substr(idcard,1,2)=35 then '福建'when substr(idcard,1,2)=36 then '江西'when substr(idcard,1,2)=37 then '山东'when substr(idcard,1,2)=41 then '河南'when substr(idcard,1,2)=42 then '湖北'when substr(idcard,1,2)=43 then '湖南'when substr(idcard,1,2)=44 then '广东'when substr(idcard,1,2)=45 then '广西'when substr(idcard,1,2)=46 then '海南'when substr(idcard,1,2)=50 then '重庆'when substr(idcard,1,2)=51 then '四川'when substr(idcard,1,2)=52 then '贵州'when substr(idcard,1,2)=53 then '云南'when substr(idcard,1,2)=54 then '西藏'when substr(idcard,1,2)=61 then '陕西'when substr(idcard,1,2)=62 then '甘肃'when substr(idcard,1,2)=63 then '青海'when substr(idcard,1,2)=64 then '宁夏'when substr(idcard,1,2)=65 then '新疆'when substr(idcard,1,2)=71 then '台湾'when substr(idcard,1,2)=81 then '香港'when substr(idcard,1,2)=82 then '澳门'when substr(idcard,1,2)=91 then '国外'else null endelse null end as province,(case when length(idcard) = 18 then substr(idcard,1,6)else null end)hj   from CITRN_VI_BAK_49) as cvb4

sql抽取身份证信息生日,年龄,星座,属性,相关推荐

  1. SQL 根据身份证号码获取年龄的函数

    在数据库的运用过程中,我们时常会碰到根据身份证号码来获取当前的年龄,今天我在这里写了一个函数,就是关于获取年龄的 create or replace function FUNC_COMPARE_SFZ ...

  2. sql提取身份证号信息--省市区县,年龄分组

    sql提取身份证号信息--省市区县,年龄分组 insert into test009 select t8.name ,t8.mobile ,t8.idcard ,t8.birthday ,t8.age ...

  3. java8 通过18位身份证号提取用户信息(年龄,生日,姓别)

    工作中经常用到的通过身份证号(18位)提取用户信息(年龄,生日,姓别),分享给大家: 先做一个javabean 存用户信息: package com;import lombok.*;import ja ...

  4. excel提取身份证出生日期_用Excel提取身份证号的年龄,不满生日的减一岁

    在人事工作中,经常需要根据身份证号来提取信息,最经典的就是要用身份证号来提取年龄,我们举例,下表是模拟的公司员工身份证号数据 1.简单提取年龄 我们知道身份证号的第7-14位是我们出生的年月日,我们可 ...

  5. python利用datetime库实现通过身份证号码判断年龄、男女,并输出生日

    python利用datetime库实现通过身份证号码判断年龄.男女,并输出生日 实现很简单,直接上代码 import datetimeID=str(input("输入身份证号码") ...

  6. Java身份证号脱敏、校验身份证号合法性、根据身份证号获取年龄、根据生日获取年龄

    这里写目录 身份证号编码规则 身份证号脱敏 身份证号合法性校验 根据身份证号获取年龄 根据生日日期获取年龄 根据身份证号获取年龄.生日的Map集合 身份证号编码规则 第一.二位表示省(自治区.直辖市. ...

  7. vue 身份证校验、识别性别/生日/年龄

    vue 身份证格式校验_chen_ai_tao的博客-CSDN博客_vue 身份证校验 Vue中根据输入的身份证号识别年龄.性别_cx&lavender的博客-CSDN博客_vue中根据省份证 ...

  8. java校验身份证的合法性、根据身份证获取生日等工具类

    文章目录 一.校验15位或者18位身份证的合法性 二.从身份证号中反向获取生日.性别等信息 一.校验15位或者18位身份证的合法性 import java.text.ParseException; i ...

  9. excel函数应用:如何用数位函数分段提取身份证信息 下篇

    在上篇内容中我们说到了用excel提取身份证号码中的户籍地址.出生日期.年龄.生肖.星座等内容,今天我们书接上回,继续带大家学习excel提取身份证信息的其他操作! 4.生日提醒 生日提醒的问题,作者 ...

最新文章

  1. spring bean的作用域和生命周期
  2. BZOJ.4199.[NOI2015]品酒大会(后缀自动机 树形DP)
  3. 渗透测试之Nmap命令(三) idle 扫描
  4. android系统(3)---dumpsys 知识学习
  5. 软件测试基础:测试用例设计
  6. 上海新中考体育考试方案公布:总分30分不变
  7. linux外接无线网卡,外接无线网卡+linux配置指南
  8. 苯小孩的伤感空间日志发布:一个人,一座城,满心疼
  9. 【爬虫】【原创】08 使用简单正则表达式爬取下厨房(早餐,午餐,晚餐)
  10. 【LeetCode每日一题】1723. 完成所有工作的最短时间
  11. java发送图片_Java发送邮件(图片、附件、HTML)
  12. 深入理解WKWebView白屏
  13. eclipse安装STS支持注意的坑
  14. DataWarehouse 数据仓库
  15. 风速风向监测报警系统
  16. 盛大半年员工扩招1千 首富陈天桥只招三种人
  17. 为什么使用reStructuredText
  18. Revit问题:降板表面填充图案和构件上色
  19. 卫生部、国家中医药管理局专题新闻发布会实录
  20. 腾讯智慧校园 php,【腾讯智慧校园1.54版本】发布

热门文章

  1. 【JavaScript】js基础第01天笔记
  2. 发布MQTT消息究竟有多快?
  3. 如何同时使用内网和外网
  4. 使用BloodHound分析域的攻击路径
  5. 裁员70%,CTO亲自写代码!(聊聊职场中年危机)
  6. cocos打包H5在iphone12/13上面播放animation后闪退
  7. 尘封的老照片修复上色,方寸之间再现温暖情怀
  8. Power Mode插件的使用
  9. 做招聘直播的好处有哪些?注意事项有?
  10. Qt 半透明背景(遮罩)