You cannot have a conditional where
clause like that. You'll need to restructure the clause so that it's a single conditional.
Maybe something like:
where
(
extract(month from sysdate) = 1
and
extract(month from r.iar_start_date) = 12
and
extract(year from r.iar_start_date) = extract(year from sysdate) - 1
)
or
(
extract(month from sysdate) <> 1
and
extract(month from r.iar_start_date) = extract(month from sysdate) - 1
and
extract(year from r.iar_start_date) = extract(year from sysdate)
)