title: Fetch Maximum data within date range without duplicate MYSQL
body: <p>I had trouble in making my queries.</p>
  
  <pre><code>SELECT * FROM YourTable AS T1
  INNER JOIN
  (SELECT user_id , MIN(some_timestamp)  AS some_timestamp FROM YourTable
  GROUP BY user_id) AS T2
  ON T1.User_Id = T2.User_Id AND T1.some_timestamp = T2.some_timestamp
  WHERE Some_Timestamp BETWEEN '13-Jun-12 08:00' AND '13-Jun-12 10:00'</code></pre>
  
  <hr>
  
  <p>Table Name: YourTable</p>
  
  <pre><code>
  | PK_ID | USER_ID |  SOME_TIMESTAMP |
  ------------------------------------|
  |     1 |     123 | 13-Jun-12 14:30 |
  |     2 |     123 | 13-Jun-12 08:50 |
  |     3 |     567 | 13-Jun-12 09:23 |
  |     4 |     567 | 13-Jun-12 09:45 |
  |     5 |     567 | 13-Jun-12 09:40 |
  |     6 |     890 | 13-Jun-12 08:44 |   
  </code></pre>
  
  <p>What i want to get is like this<br/>1. Fetch Data from specific date range between [13-Jun-12 08:00] &amp; [13-Jun-12 10:00]<br/>2. Once it fetched the date within range, it will fetch the latest date without duplicates.</p>
  
  <p>Output should be like this:<br/>
  1.date range between <pre><code>[13-Jun-12 08:00] &amp; [13-Jun-12 10:00]</code></pre><br/>
  2. Only fetching the latest timestamp without duplicates.<br/></p>
  
  <p>Results Should be like this</p>
  
  <pre><code>
  
  | PK_ID | USER_ID |  SOME_TIMESTAMP |
  ------------------------------------|
  |     2 |     123 | 13-Jun-12 08:50 |
  |     4 |     567 | 13-Jun-12 09:45 |
  |     6 |     890 | 13-Jun-12 08:44 |
  </code></pre>
  
  <p>Thank you very much everyone!</p>