Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id A0F5C47653A for ; Tue, 10 Dec 2002 11:10:16 -0500 (EST) Received: from brasileiro.net (slxwy.dorms.usu.edu [129.123.227.56]) by postgresql.org (Postfix) with ESMTP id 2ACBD475EF7 for ; Tue, 10 Dec 2002 11:09:58 -0500 (EST) Received: from roberto by brasileiro.net with local (Exim 3.35 #1 (Debian)) id 18Lmy6-0003vR-00; Tue, 10 Dec 2002 09:10:46 -0700 Date: Tue, 10 Dec 2002 09:10:46 -0700 From: Roberto Mello To: Elizabeth O'Neill's Office Mail Cc: pgsql-sql@postgresql.org Subject: Re: SQL syntax for concating values in different rows together Message-ID: <20021210161046.GI14110@cc.usu.edu> References: Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i X-message-flag: Please consider using an e-mail program other than Outlook. It's insecure. X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200212/112 X-Sequence-Number: 10700 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/ +