Postgresql – How to find similar (but different) names with the same soundex value

postgresqlpostgresql-9.3

enter image description hereI want to select the soundex value S225  for the two names

This is what iried using this query but am not getting the exact result.

I got the output with the same name and same soundex value, but I want the result which has similar name and same soundex value.

Can anyone help me to do this?

Best Answer

You can use a window function for this:

select *
from (
   select name, 
          count(*) over (partition by soundex(name)) as cnt
   from poi
) t
where cnt > 1;