Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Selecting like rows and grouping

Author  Topic 

csmith_xibe
Starting Member

1 Post

Posted - 2009-09-24 : 11:51:45

I have a table called suppliers:

ID: Name
---------------------
001 - Johnston Services inc West Bank
002 - Johnston Services Inc East Brook
003 - Johnston Services co Georgetown
004 - Mikes Towing
005 - St. Paul heating Blairsville
006 - St. Paul Heating Connelsville
007 - St. Paul Heating
008 - Some Supplier

I want to group Name to Name by their likeness to each other and output results are to be like this:

# Name
------------------------------
3 Johnston services
1 Mikes towing
3 St. Paul heating
1 Some Supplier

I didn't write the database and can not modify it, I also am toying with using Left(name,5) and grouping but that is not workng as expected - they need to be compared to each other with like...

Anyone have an idea?

Kabila
Starting Member

33 Posts

Posted - 2009-09-25 : 01:59:39
You can use the Soundex Function.

Select ID, Name,Soundex(Name) from tablename
Go to Top of Page

waterduck
Aged Yak Warrior

982 Posts

Posted - 2009-09-25 : 05:04:15
wow i first time saw soundex function...not bad


Hope can help...but advise to wait pros with confirmation...
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-09-25 : 05:28:44
quote:
Originally posted by waterduck

wow i first time saw soundex function...not bad


Hope can help...but advise to wait pros with confirmation...


select soundex('waterduck'),soundex('waterducks'),soundex('waterduckss')


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

winterh
Posting Yak Master

127 Posts

Posted - 2009-09-25 : 06:48:16
Woah Soundex. I am going to look that up now.

[ /fail at query]
Go to Top of Page
   

- Advertisement -