|
写个让你参考一下!
数据:
-------------------------------------
1 350322199010106517
2 350322701010657
SQL: (oracle下)
---------------------
select case length(b02) when 18 then to_number(to_char(sysdate,'yyyy')) -to_number(substr(b02,7,4))
when 15 then to_number(to_char(sysdate,'yyyy')) -to_number('19'||substr(b02,7,2))
end from b
where (case length(b02) when 18 then to_number(to_char(sysdate,'yyyy')) -to_number(substr(b02,7,4))
when 15 then to_number(to_char(sysdate,'yyyy')) -to_number('19'||substr(b02,7,2))
end) between '10' and '20'
RESULT:
----------------
1 18
_____________________________
[ 本帖最后由 cosio 于 2008-7-3 23:31 编辑 ]
|