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: CONCATENATE a field's values when GROUPING BY another field

Re: CONCATENATE a field's values when GROUPING BY another field

From: Daniel Morgan <damorgan_at_exxesolutions.com>
Date: Wed, 02 Jul 2003 09:11:19 -0700
Message-ID: <3F030426.4784F185@exxesolutions.com>


"Vincent C." wrote:

> Hello all,
>
> I have a tricky SQL question. The following query
>
> select username, expertise_code from exp_expertise where username =
> 'francesco';
>
> returns the 5 lines below:
>
> USERNAME EXPERTISE_CODE
> ----------------------- --------------
> francesco A02
> francesco G
> francesco G05
> francesco A11
> francesco A03
>
> But I'd rather have only one line like this:
>
> USERNAME EXPERTISE_CODE
> ----------------------- --------------
> francesco A02,G,G05,A11,A03
>
> In other words, I would like to "GROUP BY username" and find a way
> (with some aggregate function?) to concatenate the values for the
> EXPERTISE_CODE field (using a separator like a comma).
>
> Any idea?
>
> Thanks a lot.
> Vincent

Two suggestions.

  1. Don't multipost.
  2. Use a cursor loop.
--
Daniel Morgan
http://www.outreach.washington.edu/extinfo/certprog/oad/oad_crs.asp
damorgan_at_x.washington.edu
(replace 'x' with a 'u' to reply)
Received on Wed Jul 02 2003 - 11:11:19 CDT

Original text of this message

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