I have someone helping me with ZERO Jet experience, but lots of oracle experience.
There are 3 tables. SRF - CONNECT - EM
The idea is to get the latest decision_date from SRF, but if that is not available because there are only rows returned from the EM table then the latest decision_date from it instead.
What I have below cause access to crash. Each table has about 10,000 rows in it at the moment and the CONNECT about 20,000.
Please forgive me if I have not set this out properly.
I would appreciate some help.
There are 3 tables. SRF - CONNECT - EM
The idea is to get the latest decision_date from SRF, but if that is not available because there are only rows returned from the EM table then the latest decision_date from it instead.
What I have below cause access to crash. Each table has about 10,000 rows in it at the moment and the CONNECT about 20,000.
Please forgive me if I have not set this out properly.
Code:
SELECT srf1.akz, srf1.decision_number, srf1.decision_date
FROM SRF as srf1
WHERE srf1.decision_date = (SELECT max(srf1.decision_date)
FROM SRF srf2
WHERE srf1.akz = srf2.akz
GROUP by srf2.akz)
UNION SELECT em1.akz, em1.decision_number, em1.decision_date
FROM EM AS em1
WHERE em1.decision_date = (SELECT max(em1.decision_date)
FROM EM em2
Where em1.akz = em2.akz
GROUP BY em2.akz)
and not exists (SELECT 1
FROM CONNECT jt
WHERE em1.akz = jt.em_akz)
ORDER BY srf1.decision_date;
I would appreciate some help.