title: Merge duplicate records into 1 records with the same table and table fields
body: <p>I have a database table that contains a list of demographic records, some of those participant might have multiple/duplicate records, e.g.
  <br><br>
  NOTE: <br>
  Gender:<br>
  119 = Male<br>
  118 = Female<br></p>
  
  <p>Race:<br>
  255 = white<br>
  253 = Asian<br></p>
  
  <p>UrbanRural:<br>
  331 = Urban <br>
  332 = Rural <br></p>
  
  <pre><code>participantid, gender, race, urbanrural, moduletypeid, hibernateid, and more fields
  1, 119, 0, 331, 1, 1, .....
  1, 119, 255, 0, 2, 2, .....
  1, 0, 255, 331, 3, 3, .....
  1, 119, 253, 331, 0, 4, .....
  </code></pre>
  
  <p>The output should be keep the first hibernateid and the duplicate records will be merge to the first hibernatedid record. If you can do this using function that will check the records if duplicate that would be great, after merged the records it delete the unused duplicate records. Your answer gives me a great idea to resolved this problem. Thanks</p>
  
  <p>Output should be:</p>
  
  <pre><code>participantid, gender, race, urbanrural, moduletypeid, hibernateid, and more fields
  1, 119, 255, 331, 1, 1, .....
  </code></pre>
  
  <p><br>
  Help me guys, Thanks</p>