title: Selecting max record for each user
body: <p>This seems if it should be fairly simple, but I'm stumbling in trying to find a solution that works for me. </p>
  
  <p>I have a member_contracts table that has the following (simplified) structure.</p>
  
  <pre><code>MemberID | ContractID   | StartDate | End Date |
  ------------------------------------------------
  1          1              2/1/2002    2/1/2003
  2          2              3/1/2002    3/1/2003
  3          3              4/1/2002    4/1/2003
  1          4              2/1/2002    2/1/2004
  2          5              3/1/2003    2/1/2004
  3          6              4/1/2003    2/1/2004
  </code></pre>
  
  <p>I'm trying to create a query that will select the most recent contracts from this table. That being the following output for this small example:</p>
  
  <pre><code>MemberID | ContractID   | StartDate | End Date |
  ------------------------------------------------
  1          4              2/1/2002    2/1/2004
  2          5              3/1/2003    2/1/2004
  3          6              4/1/2003    2/1/2004
  </code></pre>
  
  <p>Doing this on a per-user basis is extremely simple since I can just use a subquery to select the max contractID for the specified user. I am using SQL server, so if there's a special way of doing it with that flavor, I'm open to using it. Personally, I'd like something that was engine agnostic. </p>
  
  <p>But, how would I go about writing a query that would accomplish the goal for all the users?</p>
  
  <p>EDIT: I should also add that I'm looking for the max contractID value for each user, not the most recent dates. </p>