## Syntax ```mermaid %{init: { 'theme': 'base', 'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' }, 'themeVariables': { 'fontSize': '11px', 'fontFamily': 'Arial' } }}% flowchart LR Start((START)) --> LEVENSHTEIN_RATIO[LEVENSHTEIN_RATIO]:::quoted LEVENSHTEIN_RATIO --> End((END)) ``` ## Purpose The `LEVENSHTEIN_RATIO` SQL function says how much of two values is shared when they are read in order, on a scale from zero to one. It is one minus the distance which [[Invantive UniversalSQL/Grammar/SQL Functions/LEVENSHTEIN|LEVENSHTEIN]] reports, divided by the summed lengths of the two values. That distance counts a substitution as a deletion plus an insertion, so the ratio is the figure which is elsewhere called a sequence ratio. Parameters: - Text 1 (`varchar2`): the first value. - Text 2 (`varchar2`): the second value. Returns: the ratio as `double`, from zero to one. Returns `null` when one of the values is `null`. ## Examples The following example compares two identical values: ```sql select levenshtein_ratio('test', 'test') ------------------- 1 ``` The following example compares two values which differ in one letter; the substitution costs two of the eight characters, so three quarters is shared: ```sql select levenshtein_ratio('test', 'text') ------------------- 0,75 ``` The following example compares two values which share no letter at all: ```sql select levenshtein_ratio('abc', 'xyz') ------------------- 0 ```