Like this:
select distinct id, name from (select distinct x.id, x.NAME, length(x.NAME) as leng, substr(x.name, level, 1) as namechar from YourTable x start with level = 0 connect by level <= length(x.name)) y where exists (select 'x' from YourTable z where instr(z.name, y.namechar) > 0 and z.id <> y.id) order by id
What does he do:
First (internal selection) use a table with a number generator that returns a number for each letter in the name. Now each entry in YourTable returns Length(Name) times, each with a different number. This generated number is used to highlight this letter (substr).
Then (sub-query in the top-level sentence) check if there are records containing this isolated letter. It is required to select because records are returned more than once if several letters correspond. You can add a namechar to the external list of selection fields to see the letter that matches.
source share