Re: Putting many related fields as an array

From: Sam Mason <sam(at)samason(dot)me(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Putting many related fields as an array
Date: 2009-05-12 10:14:14
Message-ID: 20090512101414.GB22221@samason.me.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Tue, May 12, 2009 at 01:23:14PM +0800, Ow Mun Heng wrote:
> | sum of count | sum_of_count_squared | qty | qty < 100 | qty < 500 |
>
>
> I'm thinking of lumping them into 1 column via an array instead of into
> 5 different columns. Not sure how to go about this, hence the email to
> the list.

The normal array constructor should work:

SELECT ARRAY[MIN(v),MAX(v),AVG(v),STDEV(v)]
FROM (VALUES (1),(3),(4)) x(v);

Not sure why this is better than using separate columns though. Maybe a
new datatype and a custom aggregate would be easier to work with?

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Sam Mason 2009-05-12 10:16:34 Re: Unable to access table named "user"
Previous Message Markus Wollny 2009-05-12 10:04:58 Could not open file "pg_clog/...."