pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dani Castaños <dcastanos@androme.es>
To: pgsql-sql@postgresql.org
Subject: Extracting data from arrays
Date: Mon, 18 May 2009 12:45:10 +0200
Message-ID: <003b01c9d7a5$b7b22190$271664b0$@es> (raw)

Hi all,

I've this query including arrays:

SELECT hour[1:5], statistics_date
  FROM statistics_daily
 WHERE statistics_date = to_date( '03/01/2008', 'DD/MM/YYYY' )

Result:

            hour            | statistics_date
----------------------------+-----------------
 {1800,1800,1800,1800,1800} | 2008-01-03


I'm just wondering if there's some way to retrieve the hour column as the
sum of the array values... Just like this:

            hour            | statistics_date
----------------------------+-----------------
 9000                       | 2008-01-03


Hour is a bigint[] array column.
My version of postreSQL is 8.1.9

Thank you in advanced!

--
Dani Castaños Sánchez
dcastanos@androme.es





view thread (4+ messages)  latest in thread

Message-ID: <003b01c9d7a5$b7b22190$271664b0$@es>
Permalink:  ../003b01c9d7a5$b7b22190$271664b0$@es/
Also on:    postgresql.org/message-id/003b01c9d7a5$b7b22190$271664b0$@es

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: dcastanos@androme.es
  Subject: Re: Extracting data from arrays
  In-Reply-To: <003b01c9d7a5$b7b22190$271664b0$@es>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox