I have a monitoring system. Retrieves the user's location every 5 seconds. However, I want to show only the records that appear in the range every 15 seconds (for example). The main idea is that it is dynamic, where the user of the system can make this switch, being 10, 15, 20 or 60, etc. One of the filters would be the start date and end date to fetch those records. See the following table below:
+------------+-------------------+
| ID | data |
+------------+-------------------+
| 1 |2017-07-10 10:11:10|
+------------+-------------------+
| 2 |2017-07-10 10:11:15|
+------------+-------------------+
| 3 |2017-07-10 10:11:20|
+------------+-------------------+
| 4 |2017-07-10 10:11:25|
+------------+-------------------+
| 5 |2017-07-10 10:11:30|
+------------+-------------------+
| 6 |2017-07-10 10:11:35|
+------------+-------------------+
| 7 |2017-07-10 10:11:44|
+------------+-------------------+
| 8 |2017-07-10 10:12:18|
+------------+-------------------+
I would like a query to return only the data that has a difference of 15 seconds (for example) between the previous date. For this example above, I would return the following lines:
+------------+-------------------+
| ID | data |
+------------+-------------------+
| 1 |2017-07-10 10:11:10|
+------------+-------------------+
| 4 |2017-07-10 10:11:25|
+------------+-------------------+
| 7 |2017-07-10 10:11:40|
+------------+-------------------+
| 8 |2017-07-10 10:12:18|
+------------+-------------------+
I do not want to be returned all database data in a date range , but return only some data by skipping some lines based on a time, for example, 15 seconds.
How would this query be?