Re: Aggregates in WHERE clause?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Aggregates in WHERE clause?
Дата
Msg-id 16867.1221134603@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Aggregates in WHERE clause?  ("Richard Broersma" <richard.broersma@gmail.com>)
Список pgsql-sql
"Richard Broersma" <richard.broersma@gmail.com> writes:
> On Wed, Sep 10, 2008 at 4:11 PM, Ruben Gouveia <rubes7202@gmail.com> 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


В списке pgsql-sql по дате отправления:

Предыдущее
От: Craig Ringer
Дата:
Сообщение: Re: pg_restore in java connection (auto_commit = false)
Следующее
От: "Igor Neyman"
Дата:
Сообщение: Re: Aggregates in WHERE clause?