I need to do a Join between 2 tables where I need only to display the last record of the 2nd table (only 1 record of table 2 for each record of table 1).
SELECT a.Campo1, a.Campo2, a.Campo3, a.Campo4, b.Campo1, b.Campo2
FROM Tabela1 a
LEFT JOIN Tabela2 b ON b.Campo1 = a.Campo1 AND (b.Campo2 = (SELECT b.Campo2 FROM Tabela2 c WHERE c.Campo1 = a.Campo1) AND ROWNUM = 1)
trying this way returns the error:
ORA-01799: A column can not be externally bound to a subquery
Can anyone help me?