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 D8D4730EABF for ; Sat, 14 Jun 2003 23:32:01 +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 36301-01 for ; Sat, 14 Jun 2003 20:31:51 -0300 (ADT) Received: from mobile.hub.org (u153n214.eastlink.ca [24.224.153.214]) by svr1.postgresql.org (Postfix) with ESMTP id 6F7F830E99B for ; Sat, 14 Jun 2003 20:31:51 -0300 (ADT) Received: by mobile.hub.org (Postfix, from userid 1001) id A15A9426; Sat, 14 Jun 2003 20:31:50 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by mobile.hub.org (Postfix) with ESMTP id 931673E6 for ; Sat, 14 Jun 2003 20:31:50 -0300 (ADT) Date: Sat, 14 Jun 2003 20:31:50 -0300 (ADT) From: The Hermit Hacker X-X-Sender: scrappy@hub.org To: pgsql-sql@postgresql.org Subject: WHERE of an AGGREGATE ... Message-ID: <20030614202831.U27289@hub.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200306/131 X-Sequence-Number: 13889 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