| From: | "Igor Neyman" <ineyman(at)perceptron(dot)com> |
|---|---|
| To: | "Ruben Gouveia" <rubes7202(at)gmail(dot)com>, "pgsql-sql" <pgsql-sql(at)postgresql(dot)org> |
| Subject: | Re: Aggregates in WHERE clause? |
| Date: | 2008-09-11 12:43:04 |
| Message-ID: | F4C27E77F7A33E4CA98C19A9DC6722A2037201FB@EXCHANGE.corp.perceptron.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
select employee,count(distinct tasks),
greatest(max(last_job_date),max(last_position_date))
from job
group by employee
having greatest(max(last_job_date),max(last_position_date)) <
2008-08-28 + integer '1';
________________________________
From: pgsql-sql-owner(at)postgresql(dot)org
[mailto:pgsql-sql-owner(at)postgresql(dot)org] On Behalf Of Ruben Gouveia
Sent: Wednesday, September 10, 2008 7:11 PM
To: pgsql-sql
Subject: [SQL] Aggregates in WHERE clause?
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?
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Emi Lu | 2008-09-11 13:48:36 | Re: pg_restore in java connection (auto_commit = false) |
| Previous Message | Tom Lane | 2008-09-11 12:03:23 | Re: Aggregates in WHERE clause? |