0

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

table

the result with my code

Shadow
  • 33,525
  • 10
  • 51
  • 64
Hamza
  • 7
  • 3
  • Please don’t link to images, add all relevant information directly to your question as editable text. What is your issue with your current solution and what do you mean by more optimal or simpler, in this context? – NickW Mar 10 '23 at 21:40

0 Answers0