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 578A930D1C0; Sat, 14 Jun 2003 23:57:33 +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 39259-06; Sat, 14 Jun 2003 20:57:23 -0300 (ADT) Received: from smtp-out8.blueyonder.co.uk (smtp-out8.blueyonder.co.uk [195.188.213.11]) by svr1.postgresql.org (Postfix) with ESMTP id 6336530D174; Sat, 14 Jun 2003 20:57:22 -0300 (ADT) Received: from [192.168.0.41] ([80.192.87.86]) by smtp-out8.blueyonder.co.uk with Microsoft SMTPSVC(5.0.2195.5329); Sun, 15 Jun 2003 00:57:21 +0100 Subject: Re: WHERE of an AGGREGATE ... From: deststar To: The Hermit Hacker Cc: pgsql-sql@postgresql.org In-Reply-To: <20030614202831.U27289@hub.org> References: <20030614202831.U27289@hub.org> Content-Type: text/plain Organization: Message-Id: <1055635083.2816.6.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-5) Date: 15 Jun 2003 00:58:03 +0100 Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 14 Jun 2003 23:57:21.0974 (UTC) FILETIME=[B2232560:01C332D0] X-Archive-Number: 200306/132 X-Sequence-Number: 13890 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