Answer the question
In order to leave comments, you need to log in
Is it possible to set such a condition for the selection?
I can’t figure it out, please tell me who has come across or just figured it out))
I need to get the last record from the database, in a row, but until the date between the previous and next record is greater than the specified parameter.
For example:
id | data | dt
231 | text... | 2019-12-31 15:07:00
230 | text... | 2019-12-31 15:06:00
229 | text... | 2019-12-31 15:05:00
228 | text... | 2019-12-31 15:04:00
227 | text... | 2019-12-31 15:01:00
226 | text... | 2019-12-31 15:00:00
entries from 228 to 231 inclusive are 1 minute apart, and 227 is already 3 minutes away!
so I would get all the records not lower than 228, the rest are not needed
records can be a different number, from one to several hundred
I want to set a range and get the number of lines corresponding to the condition described above,
and I would like to do this purely with a request, without scripts
Answer the question
In order to leave comments, you need to log in
possibly. read about window functions. lead(), lag()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question