Can someone help in simplifying below query. Cost of it shows as 58.
b.dueDate and b.tID are composite key. a.tID is primary key and foreign key between table 1 and 2.
SELECT test.tID, test.sor_acct_id, test.pmt, test.status FROM ct.tab1 a,
(SELECT a.tID, a.sor_acct_id, b.dueDate, b.amt, b.status, a.pmt,
Row_number() OVER ( partition BY a.tID ORDER BY b.dueDate DESC) AS rn
FROM ct.tab1 a
INNER JOIN ct.tab2 b
ON a.tID = b.tID
WHERE a.tID IN (SELECT a.tID
FROM ct.tab1 a
INNER JOIN
ct.tab2 b
ON a.tID =
b.tID
WHERE a.status = 'E'
AND a.pmt IS NOT NULL
AND a.pmt <> '{}'
AND b.dueDate > CURRENT_DATE - 4
AND b.dueDate < CURRENT_DATE)
AND b.dueDate > CURRENT_DATE - 1
) test WHERE rn = 1
AND test.status IN ( 'X', 'Z' )
AND a.tID = test.tID