title: MAX function sql server
body: <p>I have table userlog (ID, Login (datetime), UserID, IP, UserAgengt...)</p>
  
  <p>What I want is to get all data for eachuser for newest Login.</p>
  
  <pre><code>Select UserID, MAX(Login), IP, UserAgent
  From userlog
  Group by UserID, IP, UserAgent
  </code></pre>
  
  <p>This will give me multiple records for one user if he have multiple IPs and/or UserAgent... and I want data for row which have max login date.</p>