Вот один из вариантов: найти дубликаты в столбце EMPNAME
, удалив все, кроме букв (это то, что делает '[^[:alpha:]]'
):
SQL> with test (ecode, empname) as
2 (
3 select 'E1' ,'NIKHIL' from dual union all
4 select 'E2' ,'Nikhil.' from dual union all
5 select 'E3' ,'Nikhil??' from dual union all
6 select 'E4' ,'sunita..' from dual union all
7 select 'E5' ,'sunita..' from dual union all
8 select 'E6' ,'sunita' from dual union all
9 select 'E7' ,'Mangesh' from dual union all
10 select 'E8' ,'HIREN' from dual union all
11 select 'E9' ,'HIREN.' from dual union all
12 select 'E10' ,'HIREN??' from dual union all
13 select 'E11' ,'Viren' from dual
14 ),
15 inter as
16 (select ecode, empname, upper(regexp_replace(empname, '[^[:alpha:]]', '')) rc
17 from test
18 )
19 select ecode, empname
20 from inter
21 where rc in (select rc from inter
22 group by rc
23 having count(*) > 1
24 )
25 order by to_number(regexp_substr(ecode, '\d+$'));
ECO EMPNAME
--- --------
E1 NIKHIL
E2 Nikhil.
E3 Nikhil??
E4 sunita..
E5 sunita..
E6 sunita
E8 HIREN
E9 HIREN.
E10 HIREN??
9 rows selected.
SQL>