title: How to fetch data with time limit in MySql
body: <p>I am having below the mentioned table in MySql.</p>
  
  <pre><code>ID       UniqueId     Date
  T-1      AT-1         2018-04-03 15:16:48
  T-2      AT-1         2018-04-10 18:21:24
  T-3      AT-1         2018-04-22 13:05:16
  T-4      AT-2         2018-05-05 17:12:04
  T-5      AT-2         2018-05-15 05:03:01
  T-6      AT-2         2018-05-25 06:09:23
  T-7      AT-3         2018-06-01 06:09:23
  T-8      AT-3         2018-06-25 06:09:23
  T-9      AT-3         2018-07-01 06:09:23
  </code></pre>
  
  <p>I want to fetch only those record where the latest <code>ID</code> basis on the <code>UniqueId</code> are older than or equal to 10 days.</p>
  
  <p>For Example, <code>ID</code> T3 is the latest <code>ID</code> for <code>UniqueId</code> <code>AT-2</code> basis on date and the difference between immediate <code>ID</code> T2 is 12 days.</p>
  
  <p>Also, If this is possible with R that would also work :)</p>
  
  <p>Expected Output:</p>
  
  <pre><code>ID       UniqueId     Date                  Difference
  T-3      AT-1         2018-04-22 13:05:16   12
  T-6      AT-2         2018-05-25 06:09:23   10
  </code></pre>