I have a table with different terminals. In it, the terminal number and its different measurements are recorded every 15 minutes (that is, the terminal number will be repeated many times in the table, but each record with a different date). Example:
Now, what I need to bring the data of the last measurement for each terminal. I tried something like this:
select terminal, max(fechahora) as 'Ultima medicion' from lecturas group by terminal order by max(fechahora) desc
And obviously it brings me this:
But how do I do now to bring the other values of each of those measurements? That is, I need a table like the first, but only with the last measurement for each terminal (There would be only one record per terminal).
Thank you!