I have two columns which i want to compare, and if the strings are the same, with a maximum difference or LACK of one character, i want to make a flag to it. So for example:
select
,name1
,name2
,case when "name1 is like name2 except only 1 different character, or
lack of 1 character compared to the other" then 1
else 0
end same_flag
from example
Example output:
name1 - name 2 - sameflag
john - jon - 1
sara - sarah - 1
filip - filis - 1
phillip - philis - 0
I want it to work vica-versa. So name1 can be different from name2, but in an other row name2 can be different from name1.