From: adam etienne <a_eti@hotmail.com>
To: pgsql-sql@postgresql.org
Subject: update from multiple rows
Date: Sat, 22 Jan 2005 12:51:20 +0000
Message-ID: <BAY13-F384058140ADAAD16F8BE889830@phx.gbl> (raw)
hi
I have some trouble updating a table like this one :
date | data_raw | data_sys
12-01 | 5 | 4.5
13-01 | 6 | 6
14-01 | 7 | 8
I would like to update the 'data_sys' row by computing values of multiple
'data_raw' values. I mean for example :
data_sys(13-01) = (data_raw['12-01'] + data_raw['13-01'] +
data_raw['14-01'] )/3;
I thought of a function that fetch the 3 data_raw rows for each rows....
but it was obviously too much slow...
Is there a more efficient way to achieve this ?
Thanks in advance.. This could help me very much..
Etienne Adam
_________________________________________________________________
$BL5NA%a!<%k$J$i$d$C$Q$j(B $B!V(BMSN Hotmail$B!W(B http://www.hotmail.com/
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: a_eti@hotmail.com
Subject: Re: update from multiple rows
In-Reply-To: <BAY13-F384058140ADAAD16F8BE889830@phx.gbl>
* 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