title: Having an issue with selecting max rows by date
body: <p>I am trying to select the max timestamped records from table 1 based on some data from table 2. I am getting the correct records based on the where limits I have put on the query, but I am still getting duplicate entries not the max time stamped entries. Any ideas on what is wrong with the query?</p>
  
  <p>Basically the ID 901413368 has access to certain leveltypes and I'm trying to find out what the max dated requests were that were put in for that same person for the leveltypes that person manages.</p>
  
  <pre><code>SELECT  
  MAX(timestamp) AS maxtime, Leveltype, assign_ID
  FROM       
  WHERE 
  (leveltype IN
  (SELECT leveltype FROM  dbo.idleveltypes  WHERE   (id = 901413368)))
  GROUP BY timestamp, assign_ID, leveltype
  HAVING   (assign_ID = '901413368')
  </code></pre>
  
  <p>UPDATE: The issue has been resolved by  WEI_DBA's response below:</p>
  
  <pre><code>Remove the timestamp column from your Group By. Also put the assign_ID in     the Where Clause and remove the Having clause
  </code></pre>