Re: [SQL] Agregate Problem?
| От | Tom Lane |
|---|---|
| Тема | Re: [SQL] Agregate Problem? |
| Дата | |
| Msg-id | 10079.934732121@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: [SQL] Agregate Problem? (Herouth Maoz <herouth@oumail.openu.ac.il>) |
| Список | pgsql-sql |
> At 17:01 +0300 on 15/08/1999, Len Morgan wrote:
>> SELECT itemno,sum(qty) FROM sales WHERE sale_date = 'now()::date'
This is invalid as it stands --- you need "GROUP BY itemno" because of
the aggregate function. (IIRC, Postgres versions before 6.5 were a bit
lax about checking for that error.)
>> I would expect to get back zero rows if there were no sales today but I get
>> back 1. Of course I also get back 1 row if I only sold 1 item. Is this a
>> bug or a "feature?"
Herouth Maoz <herouth@oumail.openu.ac.il> writes:
> This is a correct behaviour when there is no GROUP BY. PostgreSQL does this
> in GROUP BY, too, unfortunately.
I believe we finally agreed that producing an empty row when there is a
GROUP BY is a bug (there was some debate about it). I intend to change
that behavior for 6.6, but haven't actually done it yet...
regards, tom lane
В списке pgsql-sql по дате отправления: