Re: Advanced SELECT

From: Richard Huxton <dev(at)archonet(dot)com>
To: Kai Hessing <kai(dot)hessing(at)hobsons(dot)de>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Advanced SELECT
Date: 2005-02-24 08:21:58
Message-ID: 421D8EA6.7020107@archonet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Richard Huxton 2005-02-24 08:30:23 Re: maximum size
Previous Message Magnus Hagander 2005-02-24 08:19:35 Re: stats collector appears to be dying

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2005-02-24 08:23:39 Re: Junk queries with variables?
Previous Message Richard Huxton 2005-02-24 08:17:46 Re: Software for database-visualisation