The DIFFERENCE function returns a value from 0 to 4 representing the difference between the sounds of two strings based on applying the SOUNDEX function to the strings. A value of 4 is the best possible sound match.
The data type of the result is INTEGER. If any argument can be null, the result can be null; if any argument is null, the result is the null value.
SELECT DIFFERENCE('CONSTRAINT','CONSTANT'), SOUNDEX('CONSTRAINT'), SOUNDEX('CONSTANT') FROM SYSIBM.SYSDUMMY1Returns 4, C523, and C523. Since the two strings return the same SOUNDEX value, the difference is 4 (the highest value possible).
SELECT DIFFERENCE('CONSTRAINT','CONTRITE'), SOUNDEX('CONSTRAINT'), SOUNDEX('CONTRITE') FROM SYSIBM.SYSDUMMY1Returns 2, C523, and C536. In this case, the two strings return different SOUNDEX values, and hence, a lower difference value.
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.