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!

Remove Duplicates From Comma Separated String

990568Feb 12 2013 — edited Feb 15 2013
Hi,
I have one Column which contains duplicates values with comma separated.

Customer ID
-----------------------------
5,5,5,5,6,6,5,5,5,6,7,4,1,2,1,4,7,2

I wrote this:

select REGEXP_REPLACE('5,5,5,5,6,6,5,5,5,6,7,4,1,2,1,4,7,2', '(^|,)([^,]*)(,\2)+','\1\2') from dual;
---------------------------------
5,6,5,6,7,4,1,2,1,4,7,2

But it eliminates only continuous elements.
I want out put like:
---------------------
5,6,7,4,1,2

Please help.
Thanks.
Amit

Edited by: 987565 on Feb 12, 2013 4:02 AM
This post has been answered by Stew Ashton on Feb 13 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 14 2013
Added on Feb 12 2013
25 comments
22,406 views