Received: from davinci.ethosmedia.com (davinci.ethosmedia.com [209.10.40.250]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0I44n095201 for ; Wed, 17 Jan 2001 23:04:50 -0500 (EST) (envelope-from josh@agliodbs.com) Received: from [209.10.40.250] (account ) by davinci.ethosmedia.com (CommuniGate Pro WebUser 3.3) with HTTP id 1178595 for ; Wed, 17 Jan 2001 20:04:45 -0800 From: "Josh Berkus" Subject: Re: update help To: pgsql-sql@postgresql.org X-Mailer: CommuniGate Pro Web Mailer v.3.3 Date: Wed, 17 Jan 2001 20:04:45 -0800 Message-ID: In-Reply-To: <22930.979787939@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit X-Archive-Number: 200101/207 X-Sequence-Number: 872 Tom, > UPDATE t1 SET amount = (select sum(b.amount) from t2 b > WHERE t1.id = b.id); Interesting. I'm used to (not necessarily in PGSQL): UPDATE t1 SET amount = t2ttl.totalamount FROM (SELECT sum(amount) as totalamount, id FROM t2 GROUP BY id) t2ttl WHERE t1.id = t2.id Although this is a subselect in the FROM clause, something we've had trouble with as I recall. -Josh Berkus