如何在oracle中找到一年前这一天的数据?

Rah*_*dya 3 sql oracle

圣诞节快乐,

我使用下面的查询来获取价格,但我的要求是从 trunc(sysdate) 获取过去一年的数据。我尝试过使用 DATEADD 函数,但它给了我一个错误

cast(p.asof as DATE) = cast(DATEADD(Year, -1, GETDATE()) as DATE)

select idvalue, p.asof as DATE_, p.instrument, p.price
from instruments i
inner join prices_equity_closing p on p.instrument = i.pkey
inner join instruments_ids id on i.ids = id.idset
where
id.idvalue in ('MRVE3.SA')
and id.idtype in ('RIC')
and p.asof = trunc(sysdate)-1
order by i.exchange, i.type, p.asof desc;
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮忙,我需要进行哪些更改才能获得所需的结果?

Jay*_*vee 7

使用 add_months 和 sysdate:

select add_months(sysdate,-12) x from dual
Run Code Online (Sandbox Code Playgroud)