pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Greg Stark <gsstark@mit.edu>
To: Marco Lazzeri <marcomail@noze.it>
Cc: pgsql-sql@postgresql.org
Subject: Re: Concatenate results of a single column query
Date: 18 Apr 2004 13:42:18 -0400
Message-ID: <87oepp6v45.fsf@stark.xeocode.com> (raw)
In-Reply-To: <1082303095.5913.3.camel@macbeth.intranet.noze.it>
References: <1082303095.5913.3.camel@macbeth.intranet.noze.it>


Marco Lazzeri <marcomail@noze.it> writes:

> SELECT
>   p.name, ARRAY(SELECT nicknames FROM people WHERE people.id = p.id)
> FROM people AS p

> Any suggestions?

Something like:

db=> create aggregate array_aggregate (basetype = integer, sfunc = array_append, stype = integer[], initcond = '{}');
CREATE AGGREGATE

db=> select array_aggregate(id) from tab;
                                                                      array_aggregate                                                                       
------------------------------------------------------------------------------------------------------------------------------------------------------------
 {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,28,29,30,31,32,33,34,36,37,38,39,40,41,42,43,27,26,44,45,46,47,48,49,50,51,52,53,54,35}
(1 row)

-- 
greg




view thread (6+ messages)  latest in thread

Message-ID: <87oepp6v45.fsf@stark.xeocode.com>
Permalink:  ../87oepp6v45.fsf@stark.xeocode.com/
Also on:    postgresql.org/message-id/87oepp6v45.fsf@stark.xeocode.com

 · 

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: gsstark@mit.edu, marcomail@noze.it
  Subject: Re: Concatenate results of a single column query
  In-Reply-To: <87oepp6v45.fsf@stark.xeocode.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