with t as ( select 1 i , 'a' n, '223456789' p from dual union all select 2 i , 'a' n, '123456789' p from dual union all select 3 i , 'b' n, '223456789' p from dual union all select 4 i , 'b' n, '223456789' p from dual union all select 5 i , 'b' n, '123456789' p from dual union all select 6 i , 'c' n, '123456789' p from dual ) select * from t where n in( select n as name from t group by n,p having count(*) > 1 )