If this doesn't work, post the DDL for both table (create table scripts) as well as some insert statements to populate some sample data and expected results:select t.docdate ,t.product ,t.unitprice ,t.qty ,t.currency ,c.exch_ratefrom ( select t.docdate ,max(c.ratedate) ratedate from transactionTable t join currencyTable c on c.currency = t.currency and c.ratedate <= t.docdate group by t.docdate ) dtsjoin transactionTable t on t.docdate = dts.docdatejoin currencyTable c on c.currency = t.currency and c.ratedate = dts.ratedate
Be One with the OptimizerTG