Search Postgresql Archives

array question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Is there any easy way to get this data:

kls_dev=# select * from ary_values;
 agent_name | myval
------------+-------
 a          |     1
 a          |     2
 a          |     3
 b          |     4
 b          |     5
 b          |     6
(6 rows)

to look like this:

kls_dev=# select * from ary_test;
 agent_name |  vals
------------+---------
 a          | {1,2,3}
 b          | {4,5,6}
(2 rows)

In other words, I would like to group by 'agent_name' and then convert
all the 'myvals' associated w/ that agent_name into an array.

I tried a few simple things like this:
kls_dev=# select array_append(myval) from ary_values group by agent_name;

but no luck so far.

Thanks,
Whit

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux