I made this request below which gives me the last contract to date (by the most recent date). I would like to know if there is a more optimal and simple way to write.
select id,contrat,date
from ( select t.* from test t
join(
select max(date) as data_date,contrat
FROM test
GROUP BY contrat
) tm on t.date = tm.data_date and t.contrat = tm.contrat
)ti