pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Roberto Mello <rmello@cc.usu.edu>
To: Elizabeth O'Neill's Office Mail <elizabeth.oneill@abcmail.co.uk>
Cc: pgsql-sql@postgresql.org
Subject: Re: SQL syntax for concating values in different rows together
Date: Tue, 10 Dec 2002 09:10:46 -0700
Message-ID: <20021210161046.GI14110@cc.usu.edu> (raw)
In-Reply-To: <BA1B8E36.1C25%elizabeth.oneill@abcmail.co.uk>
References: <BA1B8E36.1C25%elizabeth.oneill@abcmail.co.uk>

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/     +



view thread (3+ messages)  latest in thread

Message-ID: <20021210161046.GI14110@cc.usu.edu>
Permalink:  ../20021210161046.GI14110@cc.usu.edu/
Also on:    postgresql.org/message-id/20021210161046.GI14110@cc.usu.edu

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: rmello@cc.usu.edu, elizabeth.oneill@abcmail.co.uk
  Subject: Re: SQL syntax for concating values in different rows together
  In-Reply-To: <20021210161046.GI14110@cc.usu.edu>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox