Search Postgresql Archives

Re: need help with query, how to fold select result to array?

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

 



On Tue, Jan 12, 2010 at 04:06:20PM +0200, Sergey Levchenko wrote:
> but I have to fold it in multi-dimensional, array like {{71629130,
> 15518, 0}, {2668722, 616, 0}} ?
> but it's not possible to pass more then one argument to the array_agg
> function :/

Tuples work fine.  Multidimensional arrays are awfully complicated and
it's generally better to stay away from them, arrays of tuples make more
sense.  Maybe something like:

  CREATE TYPE meterreading (
    meter_id    INT, 
    org_reading NUMERIC,
    reading     NUMERIC
  );
  SELECT office_id, serial, commit_date, service_id,
    array_agg(row(meter_id, organization_reading, reading)::meterreading) AS readings
  FROM meter_readings;


-- 
  Sam  http://samason.me.uk/

-- 
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