HAMMING_DISTANCE

All functions > STRING > HAMMING_DISTANCE

Calculates the Hamming distance between two strings of equal length.

Syntax

HAMMING_DISTANCE(expr1, expr2)
sql

Arguments

ParameterTypeRequiredDescription
string1VARCHARYesFirst string to compare
string2VARCHARYesSecond string to compare

Returns

Number of positions at which the corresponding characters differ

Notes

  • Both strings must be of equal length
  • Case-sensitive comparison
  • Returns the count of differing positions
  • Useful for comparing binary strings or DNA sequences

Examples

Last update at: 2025/10/13 10:23:46