Re: [HACKERS] Problem with multiple SUMs

From: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane)
Cc: darcy(at)druid(dot)net, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Problem with multiple SUMs
Date: 1999-01-27 16:16:19
Message-ID: 199901271616.LAA08811@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Fixed.

> "D'Arcy" "J.M." Cain <darcy(at)druid(dot)net> writes:
> > After recent changes I find an error with SUM when summing more than
> > one column. ...
> > See how the individual sums are correct but I can no longer get both
> > sums in one select.
>
> Good eye!
>
> Actually, it looks like *any* two aggregates conflict --- we're
> reporting the result of the rightmost aggregate for all aggregate
> functions in a SELECT. Using D'Arcy's test table, I also tried
>
> treetest=> SELECT AVG(a), SUM(a) FROM x;
> avg|sum
> ---+---
> 3| 3
> (1 row)
>
> treetest=> SELECT AVG(a), SUM(b) FROM x;
> avg|sum
> ---+---
> 12| 12
> (1 row)
>
> treetest=> SELECT AVG(a), COUNT(b) FROM x;
> avg|count
> ---+-----
> 2| 2
> (1 row)
>
> Oops.
>
> This bug appears to explain some of the regression-test failures I'm
> seeing --- numerology and select_having both contain multiple-aggregate
> commands that are failing.
>
> In the select_having test, it looks like multiple aggregates used in
> the HAVING clause of a SELECT are suffering the same sort of fate
> as those in the target list.
>
> regards, tom lane
>
>

--
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 Bruce Momjian 1999-01-27 16:49:21 TEMP tables
Previous Message Tom Lane 1999-01-27 16:05:45 Re: [HACKERS] Re: Non-blocking queries in postgresql