clear markdown compare help best fiddles feedback
clear markdown feedback
By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0. 3601395 fiddles created (48010 in the last week).

with tab(org_name,add_line1) as ( select 'abc ', ' abc ' from dual union all select ' ab', 'abcd ' from dual ) select case when regexp_like(trim(org_name),trim(add_line1),'i') then org_name else add_line1 end as org_name from tab
ORG_NAME
abc
abcd
 hidden batch(es)


with tab(line_no,org_name,add_line1) as ( select 1,'Cottage Lane and Fairfield hospital', 'the Surgery, Fairfield hospital' from dual union all select 2,'Cottage Lane and Fairfield hospital', 'Cottage Lane and Fairfield hospital' from dual ) select line_no, case when regexp_like(trim(org_name),trim(add_line1),'i') then rtrim(org_name) || chr(32) || nvl2(rtrim(org_name), chr(32) || '\line' || chr(32), '') else rtrim(org_name) || chr(32) || nvl2(rtrim(org_name), chr(32) || '\line' || chr(32), '') || rtrim(add_line1)|| chr(32) || nvl2(rtrim(add_line1), chr(32)|| '\line' || chr(32), '') end as "POSTAL_ADDRESS" from tab
LINE_NO POSTAL_ADDRESS
1 Cottage Lane and Fairfield hospital \line the Surgery, Fairfield hospital \line
2 Cottage Lane and Fairfield hospital \line
 hidden batch(es)