X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 0A52A30DF9C for ; Sun, 15 Jun 2003 00:39:35 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 42213-01 for ; Sat, 14 Jun 2003 21:39:24 -0300 (ADT) Received: from mobile.hub.org (u153n214.eastlink.ca [24.224.153.214]) by svr1.postgresql.org (Postfix) with ESMTP id 6D9A830D171 for ; Sat, 14 Jun 2003 21:39:24 -0300 (ADT) Received: by mobile.hub.org (Postfix, from userid 1001) id 88FBD4D4; Sat, 14 Jun 2003 21:39:23 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mobile.hub.org (Postfix) with ESMTP id 31C7541F; Sat, 14 Jun 2003 21:39:23 -0300 (ADT) Date: Sat, 14 Jun 2003 21:39:23 -0300 (ADT) From: The Hermit Hacker X-X-Sender: scrappy@hub.org To: deststar Cc: pgsql-sql@postgresql.org Subject: Re: WHERE of an AGGREGATE ... In-Reply-To: <1055635083.2816.6.camel@localhost.localdomain> Message-ID: <20030614213902.M27289@hub.org> References: <20030614202831.U27289@hub.org> <1055635083.2816.6.camel@localhost.localdomain> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200306/133 X-Sequence-Number: 13891 perfect, its one of those that I've used so rarely, I never thought about it ... thanks :) On Sat, 15 Jun 2003, deststar wrote: > Isn't that what the having clause is about? > - Stuart > > On Sun, 2003-06-15 at 00:31, The Hermit Hacker wrote: > > I have a query that looks like: > > > > SELECT SUM(bytes) AS traffic > > FROM traffic_table > > GROUP BY ip; > > > > I want to narrow that SELECT down to a subset, like: > > > > SELECT SUM(bytes) AS traffic > > FROM traffic_table > > WHERE traffic < ( 100 * 1024 * 1024 ) > > GROUP BY ip; > > > > which, of course, won't work, cause I need to do the GROUP BY before I do > > the WHERE ... but there has to be a way of coding that so that it does > > work :( > > > > I'm overlooking something obvious here ... I think? > > > > Thanks ... > > > > Marc G. Fournier ICQ#7615664 IRC Nick: Scrappy > > Systems Administrator @ hub.org > > primary: scrappy@hub.org secondary: scrappy@{freebsd|postgresql}.org > > > > ---------------------------(end of broadcast)--------------------------- > > TIP 9: the planner will ignore your desire to choose an index scan if your > > joining column's datatypes do not match > > Marc G. Fournier ICQ#7615664 IRC Nick: Scrappy Systems Administrator @ hub.org primary: scrappy@hub.org secondary: scrappy@{freebsd|postgresql}.org