Предполагая, что все ваши буквы разделены одной запятой, вы можете использовать комбинацию функций replace
и trim
.
--Test data
with t(s,r) AS
(
select 'a,b,c,d,e', 'b' from dual union all
select 'a,b,c,d,e', 'e' from dual union all
select 'a,b,c,d,e', 'a' from dual union all
select 'a,b,c,d,e', 'c' from dual union all
select 'a,b,c,d,e', 'd' from dual union all
select 'a,bc,c,d,e', 'bc' from dual union all
select 'ad,bc,c,d,ef','ef' from dual union all
select 'ad,bc,c,d,ef','ad' from dual
)
select s, r as to_remove,
trim ( both ',' from replace(','||s||',', ','||r||',' ,',') ) removed
from t;
S TO_REMOVE REMOVED
a,b,c,d,e b a,c,d,e
a,b,c,d,e e a,b,c,d
a,b,c,d,e a b,c,d,e
a,b,c,d,e c a,b,d,e
a,b,c,d,e d a,b,c,e
a,bc,c,d,e bc a,c,d,e
ad,bc,c,d,ef ef ad,bc,c,d
ad,bc,c,d,ef ad bc,c,d,ef