Last Registration by date

Asked

Viewed 118 times

0

How do I return the latest update to a record example the record may have several status in one day but need to return the latest

inserir a descrição da imagem aqui

  • 1

    You can use ORDER BY in the Time and End Times: https://www.w3schools.com/sql/sql_orderby.asp

2 answers

1

To bring the highest time_end of each date use:

SELECT Ordem, Hora, MAX(hora_fim), status FROM sua_tabela
GROUP BY Hora
ORDER BY Hora;

select above will only work in Mysql if SQL mode ONLY_FULL_GROUP_BY is disabled.

0

SELECT * FROM Tabela
WHERE ordem = numero da orem
ORDER BY Hora DESC, horafim DESC
LIMIT 1;

Browser other questions tagged

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