I am trying to extract certain claims out of a table that fit specific criteria (there are around 36,000 cases in the database in total).
I want to extract all cases where an 'intervention' has either been commenced, or completed within the last 90 days and where the 'intervention type' = 2. I have used the following which seems to work, except for returning only intervention types equaling 2;
select claim_id, iv_commence_date, iv_completed_date, iv_reason
from hbintervention
where iv_commence_date> date ('today') -90 Or iv_completed_date > date('today') -90 and iv_reason = 2
I have also tried
select claim_id, iv_commence_date, iv_completed_date, iv_reason
from hbintervention
where iv_reason = 2 and iv_commence_date> date ('today') -90 Or iv_completed_date > date('today') -90
If I take the "or" section out to only return intervention type 2, then it does only return intevention type 2. However, as soon as I put it with the other conditions as above it only return the intervention types completed or commenced within 90 days.
any ideas would be much appreciated.
Thanks :)