## Syntax ```mermaid %{init: { 'theme': 'base', 'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' }, 'themeVariables': { 'fontSize': '11px', 'fontFamily': 'Arial' } }}% flowchart LR Start((START)) --> TRIGRAM_DICE[TRIGRAM_DICE]:::quoted TRIGRAM_DICE --> End((END)) ``` ## Purpose The `TRIGRAM_DICE` SQL function says how many runs of three characters two values have in common, on a scale from zero to one, as the Dice coefficient defines it: twice the shared runs divided by the summed number of runs. The order of the words does not matter, which makes it the measure to find candidates with; [[Invantive UniversalSQL/Grammar/SQL Functions/LEVENSHTEIN_RATIO|LEVENSHTEIN_RATIO]] is the measure to rank them with. Parameters: - Text 1 (`varchar2`): the first value. - Text 2 (`varchar2`): the second value. Returns: the coefficient 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 trigram_dice('licence', 'licence') ------------------- 1 ``` The following example compares two values which share no run of three characters: ```sql select trigram_dice('abcdef', 'uvwxyz') ------------------- 0 ``` The following example finds the texts of an application which resemble one another, which is what the function was added for: ```sql select src.tln_resource_code , oth.tln_resource_code , trigram_dice(src.tln_text, oth.tln_text) score from itgen_translations_v src join itgen_translations_v oth on oth.apn_code = src.apn_code and oth.lge_code = src.lge_code and oth.tln_resource_code > src.tln_resource_code where src.apn_code = 'repos/itgen/trunk' and src.lge_code = 'en' and trigram_dice(src.tln_text, oth.tln_text) >= 0.85 ```