Converting some MySQL code to work with Postgres here.
I have this query:
SELECT
tasks.task_id,
(tasks.task_dur ation * tasks.task_dura tion_type /
count(user_task s.task_id)) as hours_allocated
FROM tasks
LEFT JOIN user_tasks
ON tasks.task_id = user_tasks.task _id
WHERE tasks.task_mile stone = '0'
GROUP BY
tasks.task_id,
task_duration,
task_duration_t ype
;
The problem is that sometimes count(user_task s.task_id) equals zero,
so I get the division by zero error. Is there a simple way to make
that part of the query fail silently and just equal zero instead of
dividing and producing the error?
TIA..
--
Greg Donald
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
I have this query:
SELECT
tasks.task_id,
(tasks.task_dur ation * tasks.task_dura tion_type /
count(user_task s.task_id)) as hours_allocated
FROM tasks
LEFT JOIN user_tasks
ON tasks.task_id = user_tasks.task _id
WHERE tasks.task_mile stone = '0'
GROUP BY
tasks.task_id,
task_duration,
task_duration_t ype
;
The problem is that sometimes count(user_task s.task_id) equals zero,
so I get the division by zero error. Is there a simple way to make
that part of the query fail silently and just equal zero instead of
dividing and producing the error?
TIA..
--
Greg Donald
---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match
Comment