HAMMING_DISTANCE
All functions > STRING > HAMMING_DISTANCE
Calculates the Hamming distance between two strings of equal length.
Syntax
HAMMING_DISTANCE(expr1, expr2) sql
Arguments
| Parameter | Type | Required | Description |
|---|---|---|---|
string1 | VARCHAR | Yes | First string to compare |
string2 | VARCHAR | Yes | Second 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