Hi,
The query below takes exceptionally long to run and I reckon its because of the last line in the where clause. Can someone advise on how to speed it up? What would you change the last line to?
Cheers,
John
The query below takes exceptionally long to run and I reckon its because of the last line in the where clause. Can someone advise on how to speed it up? What would you change the last line to?
Cheers,
John
Code:
SELECT DISTINCT
MGN.APTYID,
MGN.APTYSUBACC,
PTY.APTYNAM,
MGN.AMKTCDE,
SEC.ASECNAM,
MGN.ASGDCLLSTKQTY,
TO_CHAR(MGN.AMGNDTETME,'DD-Mon-YYYY HH24:MI:SS'),
TO_CHAR(STT.ASTTDTE,'DD-Mon-YYYY')
FROM
TMGN MGN,
TPTY PTY,
TSEC SEC,
TSTT STT
WHERE
MGN.APTYID = PTY.APTYID AND
MGN.AMKTCDE = SEC.AMKTCDE AND
MGN.ASECCDE = SEC.ASECCDE AND
MGN.ASGDCLLSTKQTY <> 0 AND
SEC.ASECCDE = STT.ASECCDE(+) AND
SEC.AMKTCDE = STT.AMKTCDE(+) AND
STT.ASTTDTE = (SELECT MAX(S.ASTTDTE) FROM TSTT S WHERE SEC.ASECCDE = S.ASECCDE(+) AND SEC.AMKTCDE = S.AMKTCDE(+))