select
t1.ACCT_ID
from
account t1,
where exists
(select t2.ACCT_ID
from
exempt_account t2
where
t2.CTF_ENTY_ID = ?
and t2.EXMPT_STRT_DT = ?
and t2.EXMPT_END_DT = ?)
order by t1.ACCT_ID asc;
Problem:
I have to extract recs from exempt_account table by matching the enty_id from the enty_id that's passed in (refer to ? above) + comparing Strt_dt + End_dt dates to dates I passed in (refer to ? above).
If there is a match I then want to use enty_id to match to a rec on the account table where I capture the acct_id.
If there is no match to the exempt_account table I want to use the enty_id
that's passed in and match directly to the account table.
If rec exists in exempt_account table it's considered to be 'exempt' and I need to be able to create a field that I can later
test to determine if it came from exempt_account table or just account table.
If it only exists in account table It's non-exempt.