From: Richard Huxton <dev@archonet.com>
To: Kai Hessing <kai.hessing@hobsons.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: Advanced SELECT
Date: Thu, 24 Feb 2005 08:21:58 +0000
Message-ID: <421D8EA6.7020107@archonet.com> (raw)
In-Reply-To: <383fk1F5hq3hhU1@individual.net>
References: <383fk1F5hq3hhU1@individual.net>
Kai Hessing wrote:
>
> The normal clause would look like:
>
> SELECT c.companyname, s.sectorname FROM company c, sector s,
> company_sector cs WHERE cs.cid = c.cid AND cs.sid = s.sid ORDER BY
> c.companyname;
> c.companyname | ??? (sectors)
> ---------------+------------------------
> company1 | sectora, sectorb
> company2 | sectora, sectorb, sectorc
> company3 | sectora
> company4 | sectorc
>
Search the mailing-list archives for "custom aggregate concat" and
you'll quickly find an example of how to write your own custom aggregate
(like SUM()).
Warning - I don't think you can guarantee the order of elements in the
aggregated sectors.
--
Richard Huxton
Archonet Ltd
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-general@postgresql.org
Cc: dev@archonet.com, kai.hessing@hobsons.de, pgsql-sql@postgresql.org
Subject: Re: Advanced SELECT
In-Reply-To: <421D8EA6.7020107@archonet.com>
* 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