2
I have a monitoring system. Recovers user location every 5 seconds. However, I want to show only the records that appear in the interval every 15 seconds (for example). The main idea is that it is dynamic, where the system user can make this alternation, being 10, 15, 20 or 60, etc. One of the filters would be the start date and end date to search for these 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 that returns only the data that has difference of 15 seconds (for example) between the previous date. For this example above, return me 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 don’t want you to call me back all database data in a date range, but return only some data by skipping a few lines based on a time, for example, 15 seconds.
What would that be like query?
You part of some data?
– Marconi
@Marconi did not understand your doubt.
– viana
I say because of
2017-07-10 10:11:15
for2017-07-10 10:11:30
would have 15 seconds interval too.– Marconi
@Marconi actually, starting from the last record for example.
– viana
Be able to do in
SQL-Server
from the Initial Date =2017-07-10 10:11:10
, help you @acklay?– Marconi
@Marconi if you have something that you don’t have in Mysql I can take a look at how to adapt it. Probably, I say it probably does. Send ai. = D
– viana
Posted, I believe that just adjust the function DATEDIFF @acklay :)
– Marconi