Return a single line per code

Asked

Viewed 21 times

0

I have a table that keeps a client’s record and its duration in operation. sql needs to return me only the last client term (the most recent one). no code can be repeatedimagem da tabela simples

follows the result that sql should show me: resultado da sql

1 answer

1


Assuming your final field is DATE type:

SELECT codigo, MAX(final_vigencia) FROM sua_tabela GROUP BY codigo;
  • Very good. solved my problem!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.