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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Help with SQL to concatenate row data ...

Re: Help with SQL to concatenate row data ...

From: Daniel A. Morgan <damorgan_at_exesolutions.com>
Date: Sun, 21 Apr 2002 10:32:48 +0100
Message-ID: <3CC28740.440A9774@exesolutions.com>


This is not an appropriate thing to do with a SQL statement. Rather it should be done in a stored procedure.

I've no doubt someone can kludge together something to do it. But the maintainability would be near zero.

Daniel Morgan

Anti Spam wrote:

> I am hoping that someone can help me with a tip for a SQL problem that I
> have.
>
> Given an example table "MYCOLORS" which has the following 5 row entries:
>
> ID COLOR
> -- -----
> 1 VIOLET
> 1 INDIGO
> 2 BLUE
> 2 GREEN
> 2 YELLOW
> 3 ORANGE
>
> I would like to write SQL that produces the following output
>
> ID MIXED
> -- ------
> 1 VIOLET,INDIGO
> 2 BLUE,GREEN,YELLOW
> 3 ORANGE
>
> In other words, I am looking for a way to write a general SQL statement that
> aggregates the COLOR rows into single fields, grouped by the ID. Be advised
> that, beyond this example, I may not know how many different colors exist in
> the MYCOLORS table at any time.
>
> Can anyone help?
>
> Thanks,
> Charles
Received on Sun Apr 21 2002 - 04:32:48 CDT

Original text of this message

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