update from multiple rows - Mailing list pgsql-sql

From adam etienne
Subject update from multiple rows
Date
Msg-id BAY13-F384058140ADAAD16F8BE889830@phx.gbl
Whole thread Raw
Responses Re: update from multiple rows  (Michael Fuhr <mike@fuhr.org>)
Re: update from multiple rows  (franco <franco@akyasociados.com.ar>)
List pgsql-sql
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

_________________________________________________________________
無料メールならやっぱり 「MSN Hotmail」 http://www.hotmail.com/ 



pgsql-sql by date:

Previous
From: TJ O'Donnell
Date:
Subject: testing/predicting optimization using indexes
Next
From: Kretschmer Andreas
Date:
Subject: Question about a select