Re: Concatenate results of a single column query

From: Greg Stark <gsstark(at)mit(dot)edu>
To: Marco Lazzeri <marcomail(at)noze(dot)it>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Concatenate results of a single column query
Date: 2004-04-18 17:42:18
Message-ID: 87oepp6v45.fsf@stark.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


Marco Lazzeri <marcomail(at)noze(dot)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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Markus Bertheau 2004-04-18 18:37:53 Re: problem porting MySQL SQL to Postgres
Previous Message Marco Lazzeri 2004-04-18 15:44:55 Concatenate results of a single column query