hamming
Calculate the Hamming distance between two strings: the number of positions where their characters differ. Both strings must have the same length, and uppercase and lowercase letters count as different.
Also available as mismatches.
Try an expression
In Formula, enter the expression and set Output type to BIGINT.
Expression
hamming('duck', 'luck')Result
1To use your own data, replace the example values with column names. Keep format strings and other options as written.
Arguments and types
hamming(s1, s2)- s1
- Text
- s2
- Text
Supported signatures (1)
hamming(s1: VARCHAR, s2: VARCHAR) → BIGINTThe result type can depend on the input types. See DuckDB for the full argument rules.
Things to know
If the first argument is missing, the result is NULL.
Function metadata from DuckDB, used under the MIT license.