title: SQL Server 2008 - Get Latest Record from Joined Table
body: <p>I have a SQL Server 2008 database. This database has two tables called Customer and Order. These tables are defined as follows:</p>
  
  <pre><code>Customer
  --------
  ID,
  First Name,
  Last Name
  
  Order
  -----
  ID,
  CustomerID,
  Date,
  Description
  </code></pre>
  
  <p>I am trying to write a query that returns all of the customers in my database. If the user has placed at least one order, I want to return the information associated with the most recent order placed. Currently, I have the following:</p>
  
  <pre><code>SELECT
    *
  FROM
    Customer c LEFT OUTER JOIN Order o ON c.[ID]=o.[CustomerID]
  </code></pre>
  
  <p>As you can imagine, this will return all of the orders associated with a customer. In reality though, I only want the most recent one. How do I do this in SQL?</p>
  
  <p>Thank you!</p>