Home » Other » Training & Certification » Removing duplicates in a string.  () 1 Vote
Removing duplicates in a string. [message #286996] Mon, 10 December 2007 16:51 Go to next message
Messages: 43
Registered: October 2004
Is there a function which can do the following. I have a string say
'cat,dog,rat,cat,cat,dog' and i want the output as 'cat,dog,rat,'. The duplicates
should be removed in the string. can someone suggest a efficient way of doing this.

select some_function('cat,dog,rat,cat,cat,dog') from dual;

>> 'cat,dog,rat,'

Re: Removing duplicates in a string. [message #287014 is a reply to message #286996] Mon, 10 December 2007 23:03 Go to previous message
Michel Cadot
Messages: 63910
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You can do it in SQL:
- string to rows
- distinct
- rows to string
(search for these expressions)

By the way, this is just an exercise as you MUST never have this in a real system.
1NF says an attribute/a value/a field must be atomic.


[Updated on: Mon, 10 December 2007 23:04]

Report message to a moderator

Previous Topic: OCP Certification study material
Next Topic: Retrieving First element of a Group By Item
Goto Forum:

Current Time: Mon Oct 24 03:55:02 CDT 2016

Total time taken to generate the page: 0.06064 seconds