"Richard Broersma" <[EMAIL PROTECTED]> writes: > On Wed, Sep 10, 2008 at 4:11 PM, Ruben Gouveia <[EMAIL PROTECTED]> wrote: >> ERROR: aggregates not allowed in WHERE clause
> Having clause works on agregates. If you want to force it in the > where, you need to put the groupby in a sub-query. The way I like to think about it is "WHERE filters rows before aggregate functions are computed; HAVING filters them afterwards". Seen in those terms, it's obvious why WHERE can't contain any aggregates. regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql