From: Manfred Koizar <mkoi-pg@aon.at>
To: Andre Schubert <andre.schubert@km3.de>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to update
Date: Mon, 03 Jun 2002 15:08:46 +0200
Message-ID: <pfomfug81ska9234r96d3m58gppqimmift@4ax.com> (raw)
In-Reply-To: <20020603100028.38dd8a7e.andre.schubert@km3.de>
References: <20020603100028.38dd8a7e.andre.schubert@km3.de>
On Mon, 3 Jun 2002 10:00:28 +0200, Andre Schubert
<andre.schubert@km3.de> wrote:
>I tried this, but it update always one row in foo.
>
>update foo set inet=sum(bar.inet),local=sum(bar.local) where foo.ip = bar.ip;
Andre,
this worked in my test:
UPDATE foo
SET inet=b.i, local=b.l
FROM (SELECT ip, sum(inet) AS i, sum(local) AS l
FROM bar
GROUP BY ip) b
WHERE foo.ip = b.ip;
Servus
Manfred
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: mkoi-pg@aon.at, andre.schubert@km3.de
Subject: Re: How to update
In-Reply-To: <pfomfug81ska9234r96d3m58gppqimmift@4ax.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