Re: division by zero issue

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Greg Donald <destiney(at)gmail(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: division by zero issue
Date: 2004-09-15 18:53:13
Message-ID: 20040915185313.GG4607@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Sep 15, 2004 at 01:36:27PM -0500, Greg Donald wrote:

> I also tried Mr Fraser's suggestion:
>
> SELECT
> tasks.task_id,
> CASE
> WHEN task_count = '0'
> THEN '0'::int4
> ELSE (task_duration * task_duration_type / task_count) as hours_allocated
> END
> FROM
> (
> SELECT
> FROM tasks
> LEFT JOIN user_tasks
> ON tasks.task_id = user_tasks.task_id
> WHERE tasks.task_milestone = '0'
> GROUP BY
> tasks.task_id,
> task_duration,
> task_duration_type
> ) as intermediate;
>
> but it's producing an error near the AS for some reason I can't tell.
> I tried wrapping it with some parentheses but it didn't help.

Try putting the AS outside the CASE/END ...

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"Coge la flor que hoy nace alegre, ufana. ¿Quién sabe si nacera otra mañana?"

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Guy Fraser 2004-09-15 18:54:07 Re: division by zero issue
Previous Message Alvaro Herrera 2004-09-15 18:47:39 Re: disk performance benchmarks