去字段中的内容

来源:互联网 发布:四层别墅网络覆盖方案 编辑:程序博客网 时间:2024/05/01 08:37

处理年龄问题

AGE              AGE

007Y              7岁

045D             45天

013M             13月

SELECT
       case
          when ascii(SUBSTR(replae(patientvisit.age,' ',''), 1, 1)) >= '48' and
               ascii(SUBSTR(patientvisit.age, 1, 1)) <= '57' then
           SUBSTR(patientvisit.age, 1, 3) || (case
          when SUBSTR(patientvisit.age, 4, 1) LIKE 'Y' then
           '岁'
          when SUBSTR(patientvisit.age, 4, 1) LIKE 'M' then
           '月'
          when SUBSTR(patientvisit.age, 4, 1) LIKE 'D' then
           '天'
        END)
        WHEN ascii(SUBSTR(patientvisit.age, 2, 1)) >= '48'and ascii(SUBSTR(patientvisit.age, 2, 1)) <= '57'
        THEN SUBSTR(patientvisit.age, 2, 2) || (case
         when SUBSTR(patientvisit.age,
                     4,
                     1) LIKE 'Y' then
          '岁'
         when SUBSTR(patientvisit.age,
                     4,
                     1) LIKE 'M' then
          '月'
         when SUBSTR(patientvisit.age,
                     4,
                     1) LIKE 'D' then
          '天'
       END)
       ELSE SUBSTR(patientvisit.age, 3, 1) || (case
         when SUBSTR(patientvisit.age,
                     4,
                     1) LIKE 'Y' then
          '岁'
         when SUBSTR(patientvisit.age,
                     4,
                     1) LIKE 'M' then
          '月'
         when SUBSTR(patientvisit.age,
                     4,
                     1) LIKE 'D' then
          '天'
       END) END AS Age
  from patientvisit

原创粉丝点击