sql - How to create a MySQL query for time based elements with a 'safe window'? -


I am not a SQL expert, far from it I am writing a Rail application, and I am new to that too. I came from a desktop programming background.

My application has a table of data, one of the columns on which the data was logged. I want to create a query with a 'safe window' around every line, I mean, it gives the first line, then for x minutes (based on the time-column column) it will not return any data, x ext Once it's up, it will return the next line.

For example:

  id | Timelog 1 3/5/2010 12:01:01 2 3/5/2010 12:01:50 3 3/5/2010 12:02:03 4 3/5/2010 12:10:30 5/5/2010 01 : 30: 03 6 5/5/2010 01:31:05  

I want to make a query back with a 5-minute safe window:

  1 | 3/5/2010 12:01:01 4 3/5/2010 12:10:30 5/5/2010 01:30:03  

(This is 12:01:50 And 12:02:03 leave the objects because they happened within 5 minutes of the first item.)

Another example, I have to return the 15-minute 'safe window':

  1 | 3/5/2010 12:01:01 5 | 3/5/2010 01:30:03  

Maybe I just have to return all data and parse myself?

It is possible to use a group in a fifteen-minute slice on a column, but it is possible to use this example Does not give the necessary precise control. The best you can expect for you is sorting in a fifteen-minute bucket, but it will not guarantee a distance of fifteen minutes between the time. In fact, since 11:59:59 and 12:00:01 they are likely to be close to each other, they will be considered as two separate intervals.

Actually you are stuck using more manual method. I do not know any MySQL operation that you want.

If you need to do this operation more than once, then you know that you want to flag the special record in the database, you have specified time.


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -