Addresses stored in SQL server have many small variations(errors)

Posted by MAW74656 on Stack Overflow See other posts from Stack Overflow or by MAW74656
Published on 2011-01-06T22:02:03Z Indexed on 2011/01/07 0:54 UTC
Read the original article Hit count: 320

Filed under:
|
|

I have a table in my database which stores packing slips and their information. I'm trying to query that table and get each unique address. I've come close, but I still have many near misses and I'm looking for a way to exclude these near duplicates from my select.

Sample Data

CompanyCode   CompanyName                     Addr1                City         State   Zip
10033         UNITED DIE  CUTTING & FINISHIN  3610 HAMILTON AVE    CLEVELAND    Ohio    44114
10033         UNITED DIE CUTTING & FINISHING  3610 HAMILTON AVE    CLEVELAND    Ohio    44114
10033         UNITED DIE CUTTING & FINISHING  3610 HAMILTON AVE.   CLEVELAND    Ohio    44114
10033         UNITED DIE CUTTING & FINISHING  3610 HAMILTON AVENUE CLEVELAND    Ohio    44114
10033         UNITED DIECUTTING & FINISHING   3610 HAMILTON AVE    CLEVELAND    Ohio    44144
10033         UNITED FINISHING                3610 HAMILTON AVE    CLEVLAND     Ohio    44114
10033         UNITED FINISHING & DIE CUTTING  3610 HAMILTON AVE    CLEVELAND    Ohio    44114

And all I want is 1 record. Is there some way I can get the "Average" record? Meaning, if most of the records say CLEVELAND instead of CLEVLAND, I want my 1 record to say CLEVELAND. Is there any way to par this data down to what I'm looking for?

Desired Output

 CompanyCode   CompanyName                     Addr1                City         State   Zip
 10033         UNITED DIE CUTTING & FINISHING  3610 HAMILTON AVE    CLEVELAND    Ohio    44114

© Stack Overflow or respective owner

Related posts about sql

Related posts about tsql