DIFFERENCE

The DIFFERENCE function returns a value, from 0 to 4, that represents 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.

Read syntax diagram
>>-DIFFERENCE(expression-1,expression-2)-----------------------><

The schema is SYSIBM.

expression-1 or expression-2
Each expression must return a value that is a built-in numeric, character string, or graphic string data type that is not a LOB. A numeric argument is cast to a character string before the function is evaluated. For more information on converting a numeric string to a character string, see VARCHAR.

The data type of the result is INTEGER.

The result can be null; if any argument is null, the result is the null value.

Example 1: Find the DIFFERENCE and SOUNDEX values for 'CONSTRAINT' and 'CONSTANT':
   SELECT DIFFERENCE('CONSTRAINT','CONSTANT'),
          SOUNDEX('CONSTRAINT'),
          SOUNDEX('CONSTANT')
      FROM SYSIBM.SYSDUMMY1;
This example returns the values 4, C523, and C523. Since the two strings return the same SOUNDEX value, the difference is 4 (the highest value possible).
Example 2: Find the DIFFERENCE and SOUNDEX values for 'CONSTRAINT' and 'CONTRITE':
   SELECT DIFFERENCE('CONSTRAINT','CONTRITE'),
          SOUNDEX('CONSTRAINT'),
          SOUNDEX('CONTRITE')
      FROM SYSIBM.SYSDUMMY1;
This example returns the values 2, C523, and C536. In this case, the two strings return different SOUNDEX values, and hence, a lower difference value.