Re: multiple column to onec column

From: zab08 <zab08(at)126(dot)com>
To: "David Johnston" <polobo(at)yahoo(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: multiple column to onec column
Date: 2011-02-23 01:05:57
Message-ID: 1103da5.9ef.12e500d11f2.Coremail.zab08@126.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

thanks , this is a example of my application.

the ans is here, http://www.postgresql.org/docs/9.0/static/xaggr.html

sql command:

CREATE AGGREGATE array_accum (anyelement)
(
sfunc = array_append,
stype = anyarray,
initcond = '{}'
);

SELECT r.role_name, array_accum(permission) from roles r, roles_permissions rp group by r.role_name;

and the result:

role_name | array_accum

-----------+---------------------------------------

role2 | {permission1,permission2,permission1}

role1 | {permission1,permission2,permission1}

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rich Shepard 2011-02-23 01:10:34 Finding Errors in .csv Input Data
Previous Message David Johnston 2011-02-23 00:26:18 Re: regexp match in plpgsql