title: Getting most recent distinct records
body: <p>Considering the following table:</p>
  
  <pre>
  User  CreatedDateTime   Quantity
  ----- ----------------- --------
  Jim   2012-09-19 01:00  1
  Jim   2012-09-19 02:00  5
  Jim   2012-09-19 03:00  2
  Bob   2012-09-19 02:00  2
  Bob   2012-09-19 03:00  9
  Bob   2012-09-19 05:00  1
  </pre>
  
  <p>What query would return the most recent rows (as defined by <code>CreatedDateTime</code>) for each <code>User</code>, so that we could determine the associated <code>Quantity</code>.</p>
  
  <p>i.e. the following records</p>
  
  <pre>
  User  CreatedDateTime   Quantity
  ----- ----------------- --------
  Jim   2012-09-19 03:00  2
  Bob   2012-09-19 05:00  1
  </pre>
  
  <p>We thought that we could simply <code>Group By</code> <code>User</code> and <code>CreatedDateTime</code> and add a <code>Having MessageCreationDateTime = MAX(.MessageCreationDateTime</code>. Of course this does not work because <code>Quantity</code> is not available following the <code>Group By</code>.</p>