Answer the question
In order to leave comments, you need to log in
How to solve this problem in SQL: find the maximum window between events?
There is a table in which events are recorded, respectively, there is a field with the time of the event. How to find the maximum window between adjacent events? Those. where before. event time record - next. record time is the longest in minutes? (datediff(string_field, next_string_field))? The primary keys of the rows are inconsistently incremented.
Answer the question
In order to leave comments, you need to log in
Look towards the window functions LEAD and LAG
SELECT max(datediff(date_value, (lead(date_value) over (order by date_value))))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question