Re: division by zero issue - Mailing list pgsql-general

From Tom Lane
Subject Re: division by zero issue
Date
Msg-id 5853.1095271283@sss.pgh.pa.us
Whole thread Raw
In response to Re: division by zero issue  (Greg Donald <destiney@gmail.com>)
Responses Re: division by zero issue  (Greg Donald <destiney@gmail.com>)
List pgsql-general
Greg Donald <destiney@gmail.com> writes:
> On Wed, 15 Sep 2004 12:55:24 -0400, Jean-Luc Lachance
> <jllachan@sympatico.ca> wrote:
>> Add :
>> AND count(user_tasks.task_id) > 0 in the where clause.

> I get the error:
> aggregates not allowed in WHERE clause

You need to put it in HAVING, instead.

Note also this 7.4.4 bug fix:

* Check HAVING restriction before evaluating result list of an aggregate plan

which means that this isn't really gonna work unless you are on 7.4.5.
(It's fairly astonishing that no one noticed we were doing this in the
wrong order until recently, but no one did ...)

            regards, tom lane

pgsql-general by date:

Previous
From: John Sidney-Woollett
Date:
Subject: Re: psql + autocommit
Next
From: Ron St-Pierre
Date:
Subject: Re: disk performance benchmarks