Re: [SQL] select with group by problem

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: kaiq(at)realtyideas(dot)com
Cc: Stephan Bauer <stephan_bauer(at)gmx(dot)de>, pgsql-sql(at)postgreSQL(dot)org, Dietmar Kling <dietmar(dot)kling(at)sam-net(dot)de>
Subject: Re: [SQL] select with group by problem
Date: 1999-12-17 17:09:24
Message-ID: 8222.945450564@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

<kaiq(at)realtyideas(dot)com> writes:
> because there is a sum. sum always results something, even
> the something's value is a null ;-)

Yeah, but in GROUP BY mode, that SUM() should return one row per group.
If no input, then there are no groups, so there should be no output.
This is in fact a bug in Postgres: it produces a row anyway, which is
right for the un-GROUPed case but not when GROUPing.

The bug is fixed for the next release. In the meantime you might want
to use a workaround like adding "HAVING COUNT(*) > 0" to the query.

regards, tom lane

Browse pgsql-sql by date

  From Date Subject
Next Message Kyle 1999-12-17 18:03:56 simple sql select help
Previous Message neko 1999-12-17 15:55:55 Re: [SQL] select with group by problem