title: Get Duplicate Records and identify the lowest ID then use the lowest ID to populate Id_to_keep field
body: <p>I would like to write a script either in SQL 2008 or in VB Excel that will get all the duplicate records then on each duplicate, it will get the lowest id then use that id to populate ID_TO_KEEP field.</p>
  
  <p>Raw Data:</p>
  
  <pre><code>ID      COMPANY_NAME       ADDRESS           ZIP CODE    ID TO KEEP
  
  111     HONDA MOTORS       55 Oklahoma City    4301
  143     HONDA LTD.         55 Oklahoma City    4301
  1321    HONDA CARS         55 Oklahoma City    4301
  231     MITSUBISHI         32 Miami            5532
  342     MITSUBASHA         28 Miami            9421
  1324    MERCEDES BENZ      21 Toronto          4210
  3212    MERCEDES CARS      21 Toronto          4210
  432     MERCEDES ELECTRIC  24 Orlando          7732
  </code></pre>
  
  <p>What I want to Happen:</p>
  
  <pre><code>    ID      COMPANY_NAME       ADDRESS           ZIP CODE    ID TO KEEP
  
      111     HONDA MOTORS       55 Oklahoma City    4301         111
      143     HONDA LTD.         55 Oklahoma City    4301         111
      1321    HONDA CARS         55 Oklahoma City    4301         111
      231     MITSUBISHI         32 Miami            5532
      342     MITSUBASHA         28 Miami            9421
      1324    MERCEDES BENZ      21 Toronto          4210         1324
      3212    MERCEDES CARS      21 Toronto          4210         1324
      432     MERCEDES ELECTRIC  24 Orlando          7732
  </code></pre>
  
  <p>ID to keep column was populated since those 3 honda companies were considered as the same because they are on the same address and zip code then among those 3 honda, 111 is the lowest ID so it was the one used to populate the ID TO KEEP column on those 3 companies.</p>
  
  <p>On the mercedez benz scenario, even though mercedes electric has the same 1st name it was still not considered the same on the 2 mercedes company above because it has different address and zip code.</p>
  
  <p>Hope someone can help me with this</p>