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!

Compare 2 comma-separated columns in table

jaijeevaMay 12 2019 — edited May 13 2019

Hi,Could you please help me out to compare 2 comma-separated columns(previous_code&current_code) and split the dropped values into DROPPED_CODEĀ  column.I'm working on 11g.Here I have given sample table and data as well.

Create table t1

(id number(10),

previous_code varchar2(200),

current_code varchar2(200),

dropped_code varchar2(200)

);

insert into t1 values (1,'ABC,CDE,FGH','ABC,CDE',NULL);

insert into t1 values(1,'ABC,CDE,FGH','ABC',NULL);

insert into t1 values (1,'ABC,CDE,FGH','CDE',NULL);

COMMIT;

I have to compare PREVIOUS_CODE & CURRENT_CODE Column values and update into DROPPED_CODE field as below.

ID
PREVIOUS_CODE
CURRENT_CODEDROPPED_CODE
1ABC,CDE,FGHABC,CDEFGH
2ABC,CDE,FGHABCCDE,FGH
3ABC,CDE,FGHCDEABC,FGH

Thanks,

Jai

Comments
Post Details
Added on May 12 2019
12 comments
1,221 views