sql语句:
select pax_id_nbr, round(age/10,1),age
from (
select distinct p.pax_id_nbr pax_id_nbr,(2015-to_number(substr(p.pax_id_nbr,7,4))) age //得到唯一证件号及年龄
from pnrd p
where length(p.pax_id_nbr)=18) p //pax_id_nbr号可能是护照,所以位数限定18为身份证
where round(age/10,1)>8 //大于80岁的
其中使用到round(),顺便说一下round用法:
ROUND 返回数字表达式并四舍五入为指定的长度或精度。 语法 ROUND ( numeric_expression , length [ , function ] ) 参数 numeric_exp