0
Here is a suggested test using the Lag function to get a column value from a previous row:
select t.*
from Tabela as t
where
datediff
(minute,
lag(DataHora, 1, t.DataHora)
over(partition by id_omega order by DataHora desc),
t.DataHOra) < 60
I hope it helps
You have not informed which DBMS you are using, so make sure it provides "window functions" that will meet your needs.
– anonimo
I am using SQL Server
– Victor Hugo Hayashi
Which version of SQL Server are you using? Rows are returned in descending order of date/time and the first of the ID should always be returned?
– imex
2013, yes and yes.
– Victor Hugo Hayashi