Aggregates in WHERE clause?

From: "Ruben Gouveia" <rubes7202(at)gmail(dot)com>
To: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Aggregates in WHERE clause?
Date: 2008-09-10 23:11:13
Message-ID: 51e507b0809101611x230bf7a6if0da0760108986ea@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I tried to do the following and got the following error message:

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

********** Error **********

ERROR: aggregates not allowed in WHERE clause
SQL state: 42803

Is there away around this? Should i create a function to populate a variable
that can be used in it's place...will that even work?

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Stephan Szabo 2008-09-10 23:19:58 Re: Aggregates in WHERE clause?
Previous Message Emi Lu 2008-09-10 21:13:45 pg_restore in java connection (auto_commit = false)