Skip site navigation (1) Skip section navigation (2)

Re: Aggregates in WHERE clause?

From: Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com>
To: Ruben Gouveia <rubes7202(at)gmail(dot)com>
Cc: pgsql-sql <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Aggregates in WHERE clause?
Date: 2008-09-10 23:19:58
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-sql
On Wed, 10 Sep 2008, Ruben Gouveia wrote:

> 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

You probably want to look at some variant with HAVING, assuming you intend
those max()s to be based on the employee groups.

In response to

pgsql-sql by date

Next:From: Richard BroersmaDate: 2008-09-10 23:59:49
Subject: Re: Aggregates in WHERE clause?
Previous:From: Ruben GouveiaDate: 2008-09-10 23:11:13
Subject: Aggregates in WHERE clause?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group