title: How to write a T-SQL query to select top 1 records for each client?
body: <p>I have a simple script that I am trying to get the most recent records per client on.  How do I do this in TSQL?  This is my code currently, however, this is only selecting one record total.  This one record displays most recent record for ALL clients and not EACH client!  How can I reformulate this please?</p>
  
  <pre><code>SELECT TOP 1
  C.ClientID, actual_date
  From ClientRecords C
  WHERE (@ClientID is NULL or C.Client_ID = @ClientID)
  Group by C.ClientID, actual_date
  ORDER BY C.actual_date
  </code></pre>