title: How can I remove duplicates in SQL but keep one copy?
body: <p>I have the following table in SQL with lines of an order as follows:</p>
  
  <pre><code>RowId     OrderId     Type     Text
  ----------------------------------------
   1        1           5        "Sometext"
   2        1           5        "Sometext"
   3        2           4        "Sometext"
   4        3           5        "Sometext"
   5        2           4        "Sometext"
   6        1           3        "Sometext"
  </code></pre>
  
  <p><strong>Each order cannot have a duplicate type, but can have multiple different types.</strong></p>
  
  <p>Rows 1 and 2 are duplicates for Order <strong>1</strong>, but row 6 is fine.</p>
  
  <p>Rows 3 and 5 are duplicates for Order <strong>2</strong>.</p>
  
  <p>I need to delete all of the duplicated data, so in this case I need to delete <strong>row 2 and row 5</strong>.</p>
  
  <p>What is the best query to delete the data? Or even just return a list of <strong>RowID</strong>'s that contain duplicates to be deleted (or the opposite, a list of <strong>RowID</strong>'s to be kept)?</p>
  
  <p>Thanks.</p>