At present I am using 7.0.2 and eagerly awaiting 7.1. Following qurey gives the
answer you want. It also covers case where table test2 has some rows that have
"i" not in table test1. I am sure this will work on 6.5 too.
SELECT test1.c as c, (test1.i+test2.i) as i
SELECT test1.c as name, test1.i as i
WHERE (not exists (select * from test2 where test1.c=test2.c) )
SELECT test2.c as name, test2.i as i
WHERE (not exists (select * from test1 where test1.c=test2.c));
Timo Tuomi wrote:
> testdb=> select * from test1;
> (3 rows)
> testdb=> select * from test2;
> (2 rows)
> I'd like to get (test1.i + test2.i) like this:
> i.e. to sum the rows but if one of the rows doesn't exist on one of the tables
> then print just the existing row. How can I do this with postgresql-6.5.3?
> Thanks in advance,
> Timo T.
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
In response to
pgsql-novice by date
|Next:||From: Frank Hilliard||Date: 2001-03-22 12:51:44|
|Subject: Creating tables with Cold Fusion|
|Previous:||From: Tom Lane||Date: 2001-03-22 06:04:08|
|Subject: Re: Authentication against /etc/passwd? |