Fiz dessa forma e não deu certo! SELECT * FROM funcionario fnc LEFT JOIN altsalarial AltS on AltS.reffun = fnc.reffun where AltS.data = (select max(alts.data) from altsalarial where fnc.reffun = Alts.refFun) deu a mensagem: Cannot use an aggregate function in a WHERE clause, use HAVING instead.