Documentation

    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

    1

    To 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) → BIGINT

    The 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.

    Browse textDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.