Re: [HACKERS] Problem with multiple SUMs

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: [HACKERS] Problem with multiple SUMs
Дата
Msg-id 14086.917451046@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Problem with multiple SUMs  ("D'Arcy" "J.M." Cain <darcy@druid.net>)
Ответы Re: [HACKERS] Problem with multiple SUMs
Список pgsql-hackers
"D'Arcy" "J.M." Cain <darcy@druid.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


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Problem with multiple SUMs
Следующее
От: Bruce Momjian
Дата:
Сообщение: regression test HAVING fixed