1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| with t as ( select 'michael' c1, 'mickael' c2 from dual
union all
select 'michael' , 'mickaela' from dual
union all
select 'michael' , 'mitchell' from dual
union all
select 'michael' , 'mickey' from dual
union all
select 'oracle' , 'orkale' from dual
union all
select 'oracle' , 'creola' from dual
union all
select 'oooooo' , 'creola' from dual
union all
select 'arrivage' , 'arrimage' from dual )
select c1
, c2
, replace(translate(c1
,c2
,lpad(' '
,length(c2)) )
,' ')||' - '||replace(translate(c2
,c1
,lpad(' '
,length(c1)) )
,' ') diff_let
, abs(length(c1)-length(c2)) diff_len
, (nvl(length(replace(translate(c1,c2,lpad(' ',length(c2)) ),' ')),0)
+nvl(length(replace(translate(c2,c1,lpad(' ',length(c1)) ),' ')),0))/2 tdiff
, nvl((nvl(length(replace(translate(c1,c2,lpad(' ',length(c2)) ),' ')),0)
+nvl(length(replace(translate(c2,c1,lpad(' ',length(c1)) ),' ')),0))/2
+abs(length(c1)-length(c2)),0) tdiff_l
, UTL_MATCH.EDIT_DISTANCE(c1,c2) dist
from t
/ |
Partager