WHERE of an AGGREGATE ...

From: The Hermit Hacker <scrappy(at)postgresql(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: WHERE of an AGGREGATE ...
Date: 2003-06-14 23:31:50
Message-ID: 20030614202831.U27289@hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


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(at)hub(dot)org secondary: scrappy(at){freebsd|postgresql}.org

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message deststar 2003-06-14 23:58:03 Re: WHERE of an AGGREGATE ...
Previous Message Emmanuel Engelhart 2003-06-14 17:01:27 UNION & LIMIT & ORDER BY