Re: [SQL] select with group by problem - Mailing list pgsql-sql

From Tom Lane
Subject Re: [SQL] select with group by problem
Date
Msg-id 8222.945450564@sss.pgh.pa.us
Whole thread Raw
In response to Re: [SQL] select with group by problem  (<kaiq@realtyideas.com>)
List pgsql-sql
<kaiq@realtyideas.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


pgsql-sql by date:

Previous
From: neko@kredit.sth.szif.hu
Date:
Subject: Re: [SQL] select with group by problem
Next
From: kaf@ip146.usw5.rb1.bel.nwlink.com (Kyle)
Date:
Subject: simple sql select help