title: SQL - Group Table by entries X amount of time from each other
body: <p>I need to group together the entries in which the timestamp difference between one and the other is X amount of seconds or less than then average the value for each of them for each of the devices. In the following example I have a Table with this data and I need to group by device with entries between 60 seconds from each other.</p>
  
  <pre><code>          Device            Timestamp  Value
  0  30:8c:fb:a4:b9:8b  10/26/2015 22:50:15     34
  1  30:8c:fb:a4:b9:8b  10/26/2015 22:50:46     34
  2  c0:ee:fb:35:ec:cd  10/26/2015 22:50:50     33
  3  c0:ee:fb:35:ec:cd  10/26/2015 22:50:51     32
  4  30:8c:fb:a4:b9:8b  10/26/2015 22:51:15     34
  5  30:8c:fb:a4:b9:8b  10/26/2015 22:51:47     32
  6  c0:ee:fb:35:ec:cd  10/26/2015 22:52:38     38
  7  30:8c:fb:a4:b9:8b  10/26/2015 22:54:46     34
  </code></pre>
  
  <p>This should be the resulting Table</p>
  
  <pre><code>          Device           First_seen            Last_seen Average_value
  0  30:8c:fb:a4:b9:8b  10/26/2015 22:50:15  10/26/2015 22:51:47          33,5
  1  c0:ee:fb:35:ec:cd  10/26/2015 22:50:50  10/26/2015 22:50:51          32,5
  2  c0:ee:fb:35:ec:cd  10/26/2015 22:52:38  10/26/2015 22:52:38            38
  3  30:8c:fb:a4:b9:8b  10/26/2015 22:54:46  10/26/2015 22:54:46            34
  </code></pre>
  
  <p>Thank you very much for your help.</p>