pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: pgsql-sql@postgresql.org
Subject: Re: update help
Date: Wed, 17 Jan 2001 20:04:45 -0800
Message-ID: <web-1178595@davinci.ethosmedia.com> (raw)
In-Reply-To: <22930.979787939@sss.pgh.pa.us>

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



view thread (12+ messages)  latest in thread

Message-ID: <web-1178595@davinci.ethosmedia.com>
Permalink:  ../web-1178595@davinci.ethosmedia.com/
Also on:    postgresql.org/message-id/web-1178595@davinci.ethosmedia.com

 · 

reply

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: josh@agliodbs.com
  Subject: Re: update help
  In-Reply-To: <web-1178595@davinci.ethosmedia.com>

* 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