X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 66B6FD9C4D for ; Thu, 29 Sep 2005 16:30:02 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 29127-01 for ; Thu, 29 Sep 2005 19:29:57 +0000 (GMT) Received: from koolancexeon.g2switchworks.com (mail.g2switchworks.com [63.87.162.25]) by svr1.postgresql.org (Postfix) with ESMTP id B113ED9293 for ; Thu, 29 Sep 2005 16:29:56 -0300 (ADT) Received: mail.g2switchworks.com 10.10.1.8 from 10.10.1.37 10.10.1.37 via HTTP with MS-WebStorage 6.5.6944 Received: from state.g2switchworks.com by mail.g2switchworks.com; 29 Sep 2005 14:29:57 -0500 Subject: Re: Selecting count of details along with details columns From: Scott Marlowe To: Axel Rau Cc: Richard Huxton , pgsql-sql@postgresql.org In-Reply-To: <409f1e679d5f8744e1609d5c447d5f15@Chaos1.DE> References: <8365994213849c93946e61ded7d12318@Chaos1.DE> <433BA637.7040106@archonet.com> <433BBC07.5040208@archonet.com> <409f1e679d5f8744e1609d5c447d5f15@Chaos1.DE> Content-Type: text/plain Content-Transfer-Encoding: 7bit Message-Id: <1128022197.29347.56.camel@state.g2switchworks.com> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 (1.4.6-2) Date: Thu, 29 Sep 2005 14:29:57 -0500 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.007 required=5 tests=[AWL=0.007] X-Spam-Level: X-Archive-Number: 200509/298 X-Sequence-Number: 22845 On Thu, 2005-09-29 at 14:08, Axel Rau wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA1 > Exactly, that query works as I expected. Thank you. > Can you answer this question as well: > > Looking for a workaround, I learned that aggregate functions are not > > allowed in WHERE clauses. > > Question: Is this conform with the standard? The problem is that where clauses "fire" before group by does, so the aggregate doesn't exist yet when the where clause would be doing it's selection. Which is why the spec, and postgresql, have the "having" clause... See this part of the docs: http://www.postgresql.org/docs/8.0/interactive/sql-select.html