方法一:
SELECT TRUNC(months_between(sysdate, birth)/12) AS age
from mytable
方法二:
select TRUNC((to_char(sysdate, 'yyyyMMdd') - to_char(birth, 'yyyyMMdd')) / 10000) as age
from mytable
注:sysdate 为系统日期时间,birth 为表中出生日期字段
SELECT TRUNC(months_between(sysdate, birth)/12) AS age
from mytable
select TRUNC((to_char(sysdate, 'yyyyMMdd') - to_char(birth, 'yyyyMMdd')) / 10000) as age
from mytable
注:sysdate 为系统日期时间,birth 为表中出生日期字段