title: SQL Server - Most recent date and sale amount columns
body: <p>I'm using SQL Server 2008 R2 to complete a query. I have a sale table that contains a unique sale id, a customer id, a sale date, and a sale amount. I'm trying to create a table that has the most recent sale for each customer and the amount for that sale. </p>
  
  <pre><code>| customer_id | most recent sale date | sale amount |
  |     1       |2012-06-11 00:00:00.000|     150     |
  |     2       |2012-01-07 00:00:00.000|     55      |
  |     3       |2012-02-18 00:00:00.000|     117     |
  |     4       |2012-09-02 00:00:00.000|     25      |
  </code></pre>
  
  <p>I have the first two columns with this query:</p>
  
  <pre><code>SELECT DISTINCT customer_id, MAX(sale_date)
  FROM sale
  GROUP BY customer_id
  </code></pre>
  
  <p>When I try to add the amount of the sale, everything I try includes every sale for that customer, not just the most recent one. Is there a way to do this? Keep in mind there is a unique sale id on this table that might be of some use. Thank you for your time.</p>