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

Reply via email to