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
Nirmala
Messages: 43
Registered: October 2004
Member
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: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
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.

Regards
Michel

[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: Sat Nov 23 18:05:32 CST 2024