Find branches that have no active internal/external bank accounts
select a.branch_party_id, a.bank_branch_name, a.branch_number,
a.bank_party_id, a.bank_name, a.start_date, to_char(a.end_date, 'DD-MM-YYYY')
from ce_bank_branches_v a
where not exists
(select iba.bank_branch_id from ce_bank_accounts iba
where a.branch_party_id = iba.bank_branch_id
and nvl(iba.end_date, sysdate) >= sysdate)
and not exists
(select eba.branch_id from iby_ext_bank_accounts eba
where a.branch_party_id = eba.branch_id
and nvl(eba.end_date, sysdate) >= sysdate)