Re: [HACKERS] Problem with multiple SUMs

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: darcy(at)druid(dot)net (D'ArcyJ(dot)M(dot)Cain)
Cc: pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Problem with multiple SUMs
Date: 1999-01-27 14:29:28
Message-ID: 199901271429.JAA04718@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I am working on it.

> After recent changes I find an error with SUM when summing more than
> one column. Here is the test sequence.
>
> DROP TABLE x;
> CREATE TABLE x (a int, b int);
> INSERT INTO x VALUES (1, 5);
> INSERT INTO x VALUES (2, 7);
> SELECT * FROM x;
> SELECT SUM(a) FROM x;
> SELECT SUM(b) FROM x;
> SELECT SUM(a), SUM(b) FROM x;
>
> The last three statements give the following expected results when
> run on a system compiled Jan 19.
>
> darcy=> SELECT SUM(a) FROM x;
> sum
> ---
> 3
> (1 row)
>
> darcy=> SELECT SUM(b) FROM x;
> sum
> ---
> 12
> (1 row)
>
> darcy=> SELECT SUM(a), SUM(b) FROM x;
> sum|sum
> ---+---
> 3| 12
> (1 row)
>
> On a system compiled Jan 27, I see the following.
>
> darcy=> SELECT SUM(a) FROM x;
> sum
> ---
> 3
> (1 row)
>
> darcy=> SELECT SUM(b) FROM x;
> sum
> ---
> 12
> (1 row)
>
> darcy=> SELECT SUM(a), SUM(b) FROM x;
> sum|sum
> ---+---
> 12| 12
> (1 row)
>
> See how the individual sums are correct but I can no longer get both
> sums in one select.
>
> --
> D'Arcy J.M. Cain <darcy(at){druid|vex}.net> | Democracy is three wolves
> http://www.druid.net/darcy/ | and a sheep voting on
> +1 416 424 2871 (DoD#0082) (eNTP) | what's for dinner.
>
>

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 1999-01-27 15:30:46 Re: [HACKERS] Problem with multiple SUMs
Previous Message Bruce Momjian 1999-01-27 14:28:52 Re: Non-blocking queries in postgresql