Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Distinct column content

Re: Distinct column content

From: Thierry PLASSART <thierry.plassart_at_wanadoo.fr>
Date: Mon, 21 Feb 2005 22:18:08 +0100
Message-ID: <421a4ff9$0$3147$8fcfb975@news.wanadoo.fr>


Hi,

I suggest to write a prg to fill a new table NEW_TABLE(ID,ID2,SingleSymbol), in order to obtain records like these:
11 1 abc
11 2 bbc
11 3 abf
11 4 cde
22 1 rda

and so on... then, let's see...

declare
 cursor CurSymbol is select distinct SingleSymbol from NEW_TABLE;  counter number := 0;
answer varchar(4096); -- will it be big enough ? begin
 for RecSymbol in CurSymbol
 loop
  if (counter = 0) then
   answer := RecSymbol.SingleSymbol;
  else
   answer := answer||','||RecSymbol.SingleSymbol;   end if;
  counter := counter +1;
 end loop;
end;
dbms_output.put_line(answer);
;

I agree the prg won't be very easy...

Nevetheless, I hope it'll help!

regards,
Thierry

"Marina S." <marina.sukhnev_at_thinknet.com> a écrit dans le message de news:440f14ee.0502211258.8f815af_at_posting.google.com...
> 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,
>
> Marina
Received on Mon Feb 21 2005 - 15:18:08 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US