Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Distinct string statement
Marina S. (marina.sukhnev_at_thinknet.com) wrote:
: Hi,
: I have some question,
: I have table with 2 columns
: id symbol
: 11 abc,bbc,abf,cde
: 22 rda,abc,aig
: 33 ibm,aig,sun
: 55 aig,klm,suk,sun
: 23 bbc,kln,sun,adf
: .. ..
: .. ..
: I need to select distinct symbol strings from symbol column,they
: shoudn't be repeated,but should be comma separated as they appear in a
: column.
: the result to user should be like:
: abc,bbc,abf,cde,rda,aig,ibm,sun,klm,suk,kln,adf...
: Any ideas are really appreciated,
I assume there is a maximum number of triplets in each symbol.
So write a query to pull out all the first triplets (using various char functions), and all the second triplets, and etc.
UNION them all together. That allows you to use distinct and to ignore null triplets.
Last problem is just to display them on the same line. Here I'll assume that the display is just a reporting issue, so output the results as individual lines, but using a formatting (html or whatever) that will end up as a single line of display.
(e.g. in html
abc, bbc,
etc would create a single line of display).
How to get rid to one extra comma at the end is not immediately clear.
-- This space not for rent.Received on Mon Feb 21 2005 - 15:25:38 CST