0
I made the query below to load the records with the highest date of exit (a same record may have several dates):
SELECT RA, MAX(Data_Out) AS Data_Saida, Placa
FROM dbo.RA_Vehicles
GROUP BY RA, Placa
ORDER BY RA
I’m having difficulties when I include the column placa
(carries all records). In short, I need a query that loads the contracts and their plates with the longest date of exit (the 30 contract for example, can have two records, one with the A and X data plates and the other with the B with Y date plates. I need to load only the record with the longest date).
It would have to use an under-consumption?
is using sql server? mysql?
– rLinhares
I am using SQL server
– Saulo
I think the best thing is to do with subconsulta msm.. like this https://stackoverflow.com/a/44064826/4551469
– rLinhares