Re: update help

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: update help
Date: 2001-01-18 04:04:45
Message-ID: web-1178595@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2001-01-18 04:18:57 Re: update help
Previous Message Carolyn Lu Wong 2001-01-18 04:01:19 Re: update help