I have this Oracle query:
select sm.*
from MESSAGES sm
where sm.delivery_finished = 0
and (sm.last_sent_date is null or (SYSDATE - sm.last_sent_date) * 24 * 60 * 60 > sm.delay)
and sm.status = 'REQUEST_READY'
order by nvl(sm.last_sent_date, to_date('2000.01.01', 'yyyy-MM-dd'))
How can I rewrite this query for PostgreSQL?
I tried this:
select sm.*
from MESSAGES sm
where sm.delivery_finished = 0
and (sm.last_sent_date is null or (now() - sm.last_sent_date) * 24 * 60 * 60 > sm.delay)
AND sm.status = 'REQUEST_READY'
order by COALESCE(sm.last_sent_date, to_date('2000.01.01', 'yyyy-MM-dd'))
But on this line:
now() - sm.last_sent_date) * 24 * 60 * 60 > sm.delay
I get error:
[42883] ERROR: operator does not exist: interval > integer
Hint: An operator with the given name and types of arguments was not found. Perhaps you should add explicit type conversions. Position: 148