title: Return distinct last logon date from the following table
body: <p>I need a query in MSSQL to return the following result:</p>
  
  <p>Client ID, UserName, EventDate </p>
  
  <p>distinctly for each ClientID based on the most recent date from the following table :</p>
  
  <p><a href="https://i.stack.imgur.com/MYW71.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MYW71.png" alt="Login History table"></a></p>
  
  <p>e.g : Given the table above, return :</p>
  
  <pre><code>  450SB 2013-03-01 16:40:29 nevadan
    LASB  2013-03 001 16:37:27 siteuser
  </code></pre>
  
  <p>etc</p>
  
  <p>Was thinking of creating a cursor for a : SELECT DISTINCT ClientId from TABLE
  and looping through each returning only entry of maxdate, but didn't think it
  was very efficient.</p>