title: How to find duplicate values in SQL Server
body: <p>I'm using SQL Server 2008. I have a table</p>
  
  <pre><code>Customers
  
  customer_number int
  
  field1 varchar
  
  field2 varchar
  
  field3 varchar
  
  field4 varchar
  </code></pre>
  
  <p>... and a lot more columns, that don't matter for my queries.</p>
  
  <p>Column <em>customer_number</em> is pk. I'm trying to find duplicate values and some differences between them.</p>
  
  <p>Please, help me to find all rows that have same </p>
  
  <p><strong>1)</strong> field1, field2, field3, field4</p>
  
  <p><strong>2)</strong> only 3 columns are equal and one of them isn't (except rows from list 1)</p>
  
  <p><strong>3)</strong> only 2 columns equal and two of them aren't (except rows from list 1 and list 2)</p>
  
  <p>In the end, I'll have 3 tables with this results and additional groupId, which will be same for a group of similar (For example, for 3 column equals, rows that have 3 same columns equal will be a separate group)</p>
  
  <p>Thank you.</p>