麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 數(shù)據(jù)庫 > Oracle > 正文

Oracle按身份證號得到省市、性別、年齡的示例代碼

2020-07-26 13:25:45
字體:
供稿:網(wǎng)友

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 '內(nèi)蒙古自治區(qū)'  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 '廣西壯族自治區(qū)'  when '46' then '海南省'  when '50' then '重慶市'  when '51' then '四川省'  when '52' then '貴州省'  when '53' then '云南省'  when '54' then '西藏自治區(qū)'  when '61' then '陜西省'  when '62' then '甘肅省'  when '63' then '青海省'  when '64' then '寧夏回族自治區(qū)'  when '65' then '新疆維吾爾自治區(qū)'  when '71' then '臺灣省'  when '81' then '香港特別行政區(qū)'  when '82' then '澳門特別行政區(qū)'  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 '內(nèi)蒙古自治區(qū)'    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 '廣西壯族自治區(qū)'    when '46' then '海南省'    when '50' then '重慶市'    when '51' then '四川省'    when '52' then '貴州省'    when '53' then '云南省'    when '54' then '西藏自治區(qū)'    when '61' then '陜西省'    when '62' then '甘肅省'    when '63' then '青海省'    when '64' then '寧夏回族自治區(qū)'    when '65' then '新疆維吾爾自治區(qū)'    when '71' then '臺灣省'    when '81' then '香港特別行政區(qū)'    when '82' then '澳門特別行政區(qū)'    else '未知'end order by province desc

2、通過身份證號得到性別(第17位為奇數(shù)為男,偶數(shù)為女)

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、通過身份證號統(tǒng)計所在年齡段的人數(shù)

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、通過身份證號統(tǒng)計男女?dāng)?shù)量

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,'女','男')

總結(jié)

到此這篇關(guān)于Oracle按身份證號得到省市、性別、年齡的示例代碼的文章就介紹到這了,更多相關(guān)oracle 身份證號得到省市 性別 年齡內(nèi)容請搜索武林網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持武林網(wǎng)!

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 日本在线观看高清完整版 | 欧美18一19sex性护士农村 | 国产精品一区二区x88av | 日本aⅴ在线 | 国产视频在线免费观看 | 久久国产精品久久久久久久久久 | 久久精品视频亚洲 | 欧美成年视频 | 黄色片网站在线看 | 九九精品在线观看视频 | 99视频有精品 | 成人做爰高潮片免费视频美国 | 欧美乱淫 | 色玖玖综合 | japanese末成年free | 国产做爰 | javhdfreejaⅴhd| 黄色淫片 | 中国女警察一级毛片视频 | 激情综合视频 | 欧美一级免费视频 | 韩日黄色片 | av在线观 | 免费久久精品 | 古装三级在线观看 | 国产自在线 | 国产成人精品一区在线播放 | 性生活视频软件 | 国产精品一区2区3区 | 亚洲精品一区二区三区大胸 | 中文字幕亚洲情99在线 | 毛片a片免费看 | 成人精品一区二区三区中文字幕 | 国产999视频在线观看 | 一级国产免费 | 国产精品久久久久久久久久大牛 | 色婷婷久久久亚洲一区二区三区 | 色淫湿视频 | 羞羞视频免费网站 | 国产乱淫a∨片免费观看 | 黄色小视频免费在线观看 |