i am having an SQL query which in turn to be used as an Unload card in BMC Unload utility. Currently mu query is taking long time to execute and it is not giving me an output. I have used an order by clause in the same and i believe it is causing the problem. Because when i try executing the same with out the order by cluase it get executed fast. Can anyone suggest me some other way to implement this query and to optimise it.
the query is as follows: i want to extract 3 fields from 2 tables when mortgage value in both tables are same and also for the maximum value of application sequence.
UNLOAD DIRECT NO
FROM TABLE1 M1
WHERE N1.APPLSEQ=(SELECT MAX(N2.APPLSEQ) FROM TABLE2 N2
ORDER BY MORTGAGE