Re: Aggregates in WHERE clause?
От | Richard Broersma |
---|---|
Тема | Re: Aggregates in WHERE clause? |
Дата | |
Msg-id | 396486430809101659o4fc3b2a8o6e60a51e611af12b@mail.gmail.com обсуждение исходный текст |
Ответ на | Aggregates in WHERE clause? ("Ruben Gouveia" <rubes7202@gmail.com>) |
Ответы |
Re: Aggregates in WHERE clause?
|
Список | pgsql-sql |
On Wed, Sep 10, 2008 at 4:11 PM, Ruben Gouveia <rubes7202@gmail.com> wrote: > select employee,count(distinct tasks) > from job > where greatest(max(last_job_date),max(last_position_date)) < > 2008-08-28 + integer '1' > group by employee; > > ERROR: aggregates not allowed in WHERE clause > select employee,count(distinct tasks) from job group by employee having greatest(max(last_job_date),max(last_position_date)) < 2008-08-28 + integer '1'; Having clause works on agregates. If you want to force it in the where, you need to put the groupby in a sub-query. -- Regards, Richard Broersma Jr. Visit the Los Angeles PostgreSQL Users Group (LAPUG) http://pugs.postgresql.org/lapug
В списке pgsql-sql по дате отправления: