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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

String Compare

user572405Nov 11 2010 — edited Nov 12 2010
Pls see below the sample data
CREATE TABLE STR_TEST
(
  STR  VARCHAR2(50 BYTE)
);
commit;

Insert into STR_TEST(STR) Values ('A,B,C');
Insert into STR_TEST(STR) Values ('A,C,B');
Insert into STR_TEST(STR) Values ('D,C,A');
Insert into STR_TEST(STR) Values ('C,A,B');
Insert into STR_TEST(STR) Values ('A,B');
Insert into STR_TEST(STR) Values ('A,B,C,D');
commit;
I have to write a SQL which will compare the input string 'A,B,C' to the column STR in the above table and mark if both strings are same irrespective of the order. So, the input string matched to only the 1st 2 rows in the table:
STR       Input_STR         Match
----------------------------------
A,B,C      A,B,C                1
A,C,B      A,B,C                1
C,A,B      A,B,C                1
D,C,A      A,B,C                0
A,B        A,B,C                0
A,B,C,D    A,B,C                0 
Thank you.

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Dec 10 2010
Added on Nov 11 2010
9 comments
551 views