Re: SQL syntax for concating values in different rows together - Mailing list pgsql-sql

From Roberto Mello
Subject Re: SQL syntax for concating values in different rows together
Date
Msg-id 20021210161046.GI14110@cc.usu.edu
Whole thread Raw
In response to SQL syntax for concating values in different rows together  ("Elizabeth O'Neill's Office Mail" <elizabeth.oneill@abcmail.co.uk>)
List pgsql-sql
On Tue, Dec 10, 2002 at 12:27:34PM +0000, Elizabeth O'Neill's Office Mail wrote:
> Hi 
> 
> Can someone please help me.
> 
> I have two tables in my database a complaint table and a resolution table.
> One complaint may have several resolutions. I am trying to build a report
> that will give me the complaint details and all the resolution descriptions
> for a complaint in one text area/row (concated together).
> 
> At the moment it is repeating the complaint details for each resolution.

You could create a PL/pgSQL function that would take the id of the
resolution to query the complaints table and return the concatenation of
all the details.

That way you could just:

SELECT      id, foo, bar, concat_resolution_details(id) FROM      resolutions;

I'd give it a shot at the function, but you didn't give the structure of
the table.

-Roberto

-- 
+----|        Roberto Mello   -    http://www.brasileiro.net/  |------+
+       Computer Science Graduate Student, Utah State University      +
+       USU Free Software & GNU/Linux Club - http://fslc.usu.edu/     +


pgsql-sql by date:

Previous
From: "Elizabeth O'Neill's Office Mail"
Date:
Subject: SQL syntax for concating values in different rows together
Next
From: "Vijay Uppal"
Date:
Subject: sql query