title: SQL address data is messy, how to clean it up in a query?
body: <p>I have address data stored in an sql server 2000 database, and I need to pull out all the addresses for a given customer code.  The problem is, there are a lot of misspelled addresses, some with missing parts, etc.  So I need to clean this up somehow.  I need to weed oout the bad spellings, missing parts, etc and come up with the "average" record.  For example, if New York is spelled properly in 4 out of 5 records, that should be the value returned. </p>
  
  <p>I can't modify the data, validate it on input, or anything like that.  I can only modify a copy of the data, or manipulate it through a query.</p>
  
  <p>I got a partial answer here <a href="https://stackoverflow.com/q/4620396">Addresses stored in SQL server have many small variations(errors)</a>, but I need to allow for multiple valid addresses per code.    </p>
  
  <p>Sample Data</p>
  
  <pre>
  Code    Name                       Address1                      Address2           City            State          Zip     TimesUsed
  10003   AMERICAN NUTRITON INC     2183 BALL STREET                                 OLDEN           Utah           87401     177
  10003   AMEICAN NUTRITION INC     2183 BALL STREET              PO BOX 1504        OLDEN           Utah           87402     76
  10003   AMERICAN NUTRITION INC    2183 BALL STREET                                 OLDEN           Utah           87402     24
  10003   AMERICAN NUTRITION INC    2183 BALL STREET              PO BOX 1504        OLDEN           Utah           87402     17
  10003   Samantha Brooks           506 S. Main Street                               Ellensburg      Washington     98296     1
  10003   BEMIS COMPANY             1401 W. FOURTH PLAIN BLVD.                       VANCOUVER       Washington     98660     1
  10003   CEI                       597 VANDYRE BOULEVARD                            WRIGHTSTOWN     Wisconsin      54180     1
  10003   Pacific Pet               28th Avenue                                      OLDEN           Utah           84401     1
  10003   PETSMART, INC.            16091 NORTH 25TH STREET                          PHOENA         Arizona        85027      1
  10003   THE PET FIRM              16418 NORTH 37TH STREET                          PHOENA         Arizona        85503      1
  </pre>
  
  <p>Desired Output</p>
  
  <pre>
  Code    Name                      Address1                      Address2           City            State          Zip     
  10003   AMERICAN NUTRITION INC    2183 BALL AVENUE                                 Olden           Utah           84401
  10003   Samantha Brooks             506 S. Main Street                               Ellensburg      Washington     98296 
  10003   BEMIS COMPANY             1401 W. FOURTH PLAIN BLVD.                       VANCOUVER       Washington     98660
  10003   CEI                       975 VANDYKE ROAD                                 WRIGHTSTOWN     Wisconsin      54180
  10003   Pacific Pet               29th Street                                      OGDEN           Utah           84401
  10003   PETSMART, INC.            16091 NORTH 25TH AVENUE                          PHOENA         Arizona        85027
  10003   THE PET FIRM              16418 NORTH 37TH STREET                          PHOENA         Arizona        85503
  </pre>