title: SQL - Select newest record when there's a duplicate
body: <p>I'm writing a query, and have used the solution in <a href="https://stackoverflow.com/questions/331367/sql-statement-help-select-latest-order-for-each-customer">this thread</a> and it has worked <em>somewhat</em> but I'm still having a bit of trouble.</p>
  
  <p>I want to select a bunch of records that are for the most part unique, but there are a few that occur twice. I want to be able to only select the record that has the newest date. This is my query so far:</p>
  
  <pre><code>SELECT tb1.id,tb1.type,tb1.date
  
  FROM Table tb1  
  
  WHERE tb1.type = 'A' OR 'B'
  AND tb1.date = (SELECT TOP 1 tb2.date
                 FROM Table tb2  
                 WHERE tb2.date = tb1.date
                  ORDER BY tb2.date DESC)
  </code></pre>
  
  <p>This works as far as it retrieves the latest record of those records that have duplicates, but those records that DON'T have duplicates don't appear at all.</p>
  
  <p>Thanks for any help, and my apologies if I've missed something super obvious; I'm new to the SQL game.</p>