这个问题可能是愚蠢的,也可能是重复的,但我没有得到确切的答案
我有一个具有日期格式列(eff_date)的表,我想要sysdate和一个eff_date之间的差异超过两年且等于两年的数据
我正在使用此查询,我知道它的语法错误
select *
from Customer
where (select floor(months_between(sysdate,eff_date)/12)
from Customer t) >= 2
答案 0 :(得分:1)
如果您想使用months_between
SELECT *
FROM customer
WHERE months_between( sysdate, eff_date ) >= 24
如果eff_date
上有索引,您可能需要
SELECT *
FROM customer
WHERE eff_date <= sysdate - interval '2' year