title: SQL - Grouping duplicates and unique id issue
body: <p>hope someone can point me in the right direction.  I'm having a bit of a hair pulling moment.</p>
  
  <p>Here is some sample data:</p>
  
  <pre><code>ID    SUBID   COL1      COL2      COL2      COL3
  1     10001   Test 1    Test 2    Test 3    Test 4
  2     10002   Test 1    Test 2    Test 3    Test 4
  3     10003   Test 1    Test 2    Test 3    Test 4
  4     10004   Test 1    Test 2    Test 3    Test 4
  5     10005   Test 5    Test 6    Test 7    Test 8
  </code></pre>
  
  <p>I need the result to look like this:</p>
  
  <pre><code>ID    SUBID   COL1      COL2      COL2      COL3
  4     10004   Test 1    Test 2    Test 3    Test 4
  5     10005   Test 5    Test 6    Test 7    Test 8
  </code></pre>
  
  <p>I need to group all duplicates based on COL1, COL2, COL3 &amp; COL4 which is easy but I need to output a number from the groupings in the ID and SUBID column, it doesn't matter which of the grouped rows this comes from, it just needs a value.</p>
  
  <p>Performance is also key in doing this as I'm querying millions of rows.</p>
  
  <p>Hope the above makes sense and thank you.</p>