濮阳杆衣贸易有限公司

主頁 > 知識(shí)庫 > Oracle按身份證號(hào)得到省市、性別、年齡的示例代碼

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

熱門標(biāo)簽:汽車4s店百度地圖標(biāo)注店 安陽企業(yè)電銷機(jī)器人供應(yīng)商 地圖標(biāo)注效果的制作 鶴壁電話機(jī)器人價(jià)格 電銷套路機(jī)器人 地圖標(biāo)注坐標(biāo)圖標(biāo) 網(wǎng)貸外呼系統(tǒng)合法嗎 杭州網(wǎng)絡(luò)外呼系統(tǒng)運(yùn)營商 手機(jī)地圖標(biāo)注門店

1、通過身份證號(hào)查詢所在省市

SELECT
count(*) 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 '臺(tái)灣省'
  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 '臺(tái)灣省'
    when '81' then '香港特別行政區(qū)'
    when '82' then '澳門特別行政區(qū)'
    else '未知'end order by province desc

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

select 
  decode(mod(to_number(substr(t.useridcardnum, 17, 1)), 2),0,'女','男') as sex
 from uip_ca_userinfo t

3、通過身份證號(hào)得到年齡

select to_char(sysdate, 'yyyy') - substr(t.useridcardnum, 7, 4) as age from uip_ca_userinfo t

4、通過身份證號(hào)統(tǒng)計(jì)所在年齡段的人數(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、通過身份證號(hào)統(tǒng)計(jì)男女?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按身份證號(hào)得到省市、性別、年齡的示例代碼的文章就介紹到這了,更多相關(guān)oracle 身份證號(hào)得到省市 性別 年齡內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • oracle執(zhí)行cmd的實(shí)現(xiàn)方法
  • Oracle數(shù)據(jù)庫常用命令整理(實(shí)用方法)
  • Oracle利用errorstack追蹤tomcat報(bào)錯(cuò)ORA-00903 無效表名的問題
  • Windows10安裝Oracle19c數(shù)據(jù)庫詳細(xì)記錄(圖文詳解)
  • Shell腳本連接oracle數(shù)據(jù)庫的實(shí)現(xiàn)代碼
  • Oracle數(shù)據(jù)庫服務(wù)器修改操作系統(tǒng)時(shí)間的注意事項(xiàng)詳解
  • Linux一鍵部署oracle安裝環(huán)境腳本(推薦)
  • CMD操作oracle數(shù)據(jù)導(dǎo)庫過程圖解

標(biāo)簽:南陽 柳州 河源 焦作 銀川 酒泉 泰安 梧州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Oracle按身份證號(hào)得到省市、性別、年齡的示例代碼》,本文關(guān)鍵詞  Oracle,按,身份,證號(hào),得到,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《Oracle按身份證號(hào)得到省市、性別、年齡的示例代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于Oracle按身份證號(hào)得到省市、性別、年齡的示例代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    称多县| 泗洪县| 中西区| 六安市| 洛隆县| 扎兰屯市| 常熟市| 论坛| 临桂县| 资阳市| 莆田市| 会理县| 绍兴市| 思茅市| 庆安县| 阳谷县| 新化县| 景宁| 佛教| 静乐县| 新绛县| 上犹县| 昌邑市| 河北区| 昌江| 南宫市| 刚察县| 当阳市| 阿拉善右旗| 新田县| 衡阳县| 萝北县| 西畴县| 龙里县| 四子王旗| 呼图壁县| 建平县| 全南县| 新乡市| 翁源县| 连平县|