Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.9.3/8.9.3) with ESMTP id MAA92999 for ; Fri, 17 Dec 1999 12:10:57 -0500 (EST) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id MAA08225; Fri, 17 Dec 1999 12:09:26 -0500 (EST) To: kaiq@realtyideas.com cc: Stephan Bauer , pgsql-sql@postgreSQL.org, Dietmar Kling Subject: Re: [SQL] select with group by problem In-reply-to: Your message of Fri, 17 Dec 1999 09:26:13 -0600 (CST) Date: Fri, 17 Dec 1999 12:09:24 -0500 Message-ID: <8222.945450564@sss.pgh.pa.us> From: Tom Lane 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