<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