Answer the question
In order to leave comments, you need to log in
How to write a sql query to select dates with an interval?
There is a plate with dates in the format "2016-06-03 00:45:00" how to correctly compose a sql query to select all records between which the time interval is more than 15 minutes?
That is, if there are 3 records in the database:
2016-06-03 00:10:00
2016-06-03 00:20:00
2016-06-03 00:40:00
then it should output:
2016-06-03 00:20 :00
2016-06-03 00:40:00
Answer the question
In order to leave comments, you need to log in
The general scheme is something like this:
select A.DATE
from table
join (select A.DATE as DATE, A1.DATE as DATE1
from table A
join table A1 on A1.DATE > date_add(minute, A.DATE, 15)
) A1 on A1.DATE=A.DATE or A1.DATE1=A.DATE
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question