DIFFERENCE

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.

DIFFERENCE(expression-1,expression-2)
expression-1
An expression that returns a built-in numeric, character-string, or graphic-string data types, but not CLOBs or DBCLOBs. The arguments cannot be binary strings. A numeric argument is cast to a character string before evaluating the function. For more information about converting numeric to a character string, see VARCHAR.
expression-2
An expression that returns a built-in numeric, character-string, or graphic-string data types, but not CLOBs or DBCLOBs. The arguments cannot be binary strings. A numeric argument is cast to a character string before evaluating the function. For more information about converting numeric to a character string, see VARCHAR.

The data type of the result is INTEGER. If either argument can be null, the result can be null; if either argument is null, the result is the null value.

Examples

  • Assume the following statement:
      SELECT DIFFERENCE('CONSTRAINT','CONSTANT'),
             SOUNDEX('CONSTRAINT'),
             SOUNDEX('CONSTANT')
        FROM SYSIBM.SYSDUMMY1
    Returns 4, C523, and C523. Since the two strings return the same SOUNDEX value, the difference is 4 (the highest value possible).
  • Assume the following statement:
      SELECT DIFFERENCE('CONSTRAINT','CONTRITE'),
             SOUNDEX('CONSTRAINT'),
             SOUNDEX('CONTRITE')
        FROM SYSIBM.SYSDUMMY1
    Returns 2, C523, and C536. In this case, the two strings return different SOUNDEX values, and hence, a lower difference value.