## Syntax ```mermaid %%{init: { 'theme': 'base', 'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' }, 'themeVariables': { 'fontSize': '11px', 'fontFamily': 'Arial' } }}%% flowchart LR Start((START)) --> LEVENSHTEIN[LEVENSHTEIN]:::quoted LEVENSHTEIN --> End((END)) ``` ## Purpose The `LEVENSHTEIN` SQL function determines the Levenshtein distance between two values as defined on [Wikipedia](https://en.wikipedia.org/wiki/Levenshtein_distance). A substitution of one character counts as two steps: a deletion plus an insertion. Parameters: - Text 1 (`varchar2`): the first value. - Text 2 (`varchar2`): the second value. Returns: the Levenshtein distance as `int32`. Returns `null` when one of the values is `null` or empty. ## Examples The following example retrieves the Levenshtein distance between `test` and `teste`, requiring one insertion: ```sql select levenshtein('test', 'teste') ------------------- 1 ``` The following example retrieves the Levenshtein distance between `1234` and `4567`; the three deletions plus three insertions total six steps: ```sql select levenshtein('1234', '4567') ------------------- 6 ``` The following example retrieves the Levenshtein distance between two identical values: ```sql select levenshtein('pete', 'pete') ------------------- 0 ```