title: GROUP BY same record but different TIMESTAMP/DATETIME
body: <p>I'm trying to <code>GROUP BY</code> same records but different <code>timestamp</code> or <code>datetime</code>.
  The difference of time is only about 3 minutes from the first entry.</p>
  
  <p>example:</p>
  
  <p>This is what the database table looks like.</p>
  
  <pre><code>*-------------------------------------------*
  |   id  |   name    |         time          |
  |   1   |   Lei     | 2018-02-21 12:00:10   |
  |   2   |   Lei     | 2018-02-21 12:01:11   |
  |   3   |   Lei     | 2018-02-21 12:01:15   |
  |   4   |   Lei     | 2018-02-21 12:01:16   |
  |   5   |   Anna    | 2018-02-21 12:03:11   |
  |   6   |   Anna    | 2018-02-21 12:03:13   |
  |   7   |   Bell    | 2018-02-21 12:05:01   |
  |   8   |   Lei     | 2018-02-21 12:10:00   |
  *-------------------------------------------*
  </code></pre>
  
  <p>I want to get Lei's entry from 12:00:10 up to 3 minutes from her first <code>timestamp</code> or <code>datetime</code> record. </p>
  
  <p>so the output would be like this.</p>
  
  <pre><code>*-------------------------------------------*
  |   id  |   name    |         time          |
  |   1   |   Lei     | 2018-02-21 12:00:10   |
  |   5   |   Anna    | 2018-02-21 12:03:11   |
  |   7   |   Bell    | 2018-02-21 12:05:01   |
  |   8   |   Lei     | 2018-02-21 12:10:00   |
  *-------------------------------------------*
  </code></pre>
  
  <p>I'll be gladly appreciate your help, mysql or php it is.  </p>