SUM doesn't work on two or more columns from different tables

From: Skeets Norquist <skeetsnorquist(at)yahoo(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: SUM doesn't work on two or more columns from different tables
Date: 2000-02-01 04:02:33
Message-ID: 20000201040234.9964.qmail@web903.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

============================================================================
POSTGRESQL BUG REPORT TEMPLATE
============================================================================

Your name : Skeets Norquist
Your email address : skeetsnorquist(at)yahoo(dot)com

System Configuration
---------------------
Architecture (example: Intel Pentium)
: Intel Pentium Pro

Operating System (example: Linux 2.0.26 ELF) :
Linux 2.2.5-15 (i386) (RedHat 6.0)

PostgreSQL version (example: PostgreSQL-6.5.1) :
PostgreSQL-6.5.3-1

Compiler used (example: gcc 2.8.0)
: downloaded RPM

Please enter a FULL description of your problem:
------------------------------------------------

When you try to use the SUM aggregate on each of two
columns from different tables, the results are
incorrect.

I'm trying to select the sum of an int4 column from
one table and the sum of an int4 column from another
table but the results are incorrect for the second
sum. Sometimes the result columns look like they were
arrived at by repeatedly doubling the true sum a
varying number of times (are the bits getting
shifted?). I can't figure out the pattern.

Please describe a way to repeat the problem. Please
try to provide a
concise reproducible example, if at all possible:
----------------------------------------------------------------------

=> create table t1 (a int);
CREATE
=> insert into t1 values (1);
INSERT 155081 1
=> insert into t1 values (1);
INSERT 155082 1
=> create table t2 (a int);
CREATE
=> insert into t2 values (1);
INSERT 155092 1
=> select sum(t1.a), sum(t2.a) from t1, t2;
sum|sum
---+---
2| 2
(1 row)

If you know how this problem might be fixed, list the
solution below:
---------------------------------------------------------------------

__________________________________________________
Do You Yahoo!?
Talk to your friends online with Yahoo! Messenger.
http://im.yahoo.com

Browse pgsql-bugs by date

  From Date Subject
Next Message Marius Ciolacu 2000-02-01 12:22:06 ...
Previous Message Herr Dumont 2000-01-31 19:33:55 Correction of my bug report sent on 2000-01-28