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

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

Reply via email to