根据 出生日期 计算 年龄 sql

两个data 列可以进行相减,得到一个number 类型的数

select t.aae002,
               b.aac001,
               case
                 when ((sysdate - aac006) / 365) > 60 then  -- aac006 是data 类型
                  1
                 when ((sysdate - aac006) / 365) < 60 then
                  2
                 else
                  0
               end cc,
               t.aab170 qq
       
          from gzsi.ac80 t,ac01 c;

例子2

select (sysdate-to_date('20020105','yyyymmdd')) /365 from dual

结果为11.17945129375951293759512937595129375951

猜你喜欢

转载自joezheng123.iteye.com/blog/1826117