Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Find first and second occurance of |

user650888Oct 5 2020 — edited Oct 5 2020

create table mtest (x number,y varchar2(1000), z varchar2(1000));
insert into mtest values(1, '[AB|UUU/WWW|DATA]','[XY|UUU/WWW|DATA1]');
insert into mtest values(2, '[AB|AAA/BBB|DATA]','[TR|UUU/WWW|DATA1]');
insert into mtest values(3, '[AB|CCC/XXX|DATA]','[XY|CCC/XXX|TA1]');
commit;
I am trying to write a case statement that returns Y or N
Y -- compare y and z columns from above, compare the text between first '|' and second '|'
(example, for row 1, UUU/WWW from column y matches with UUU/WWW of column z, so case gives Y

N-- for row 2, AAA/BBB is not equal to UUU/WWW so return N,
how can i find the 1st and 2nd occurance of '|' from above examples for this comparison ?

Comments
Post Details
Added on Oct 5 2020
5 comments
173 views