Converting some MySQL code to work with Postgres here.
I have this query:
SELECT
tasks.task_id,
(tasks.task_duration * tasks.task_duration_type /
count(user_tasks.task_id)) as hours_allocated
FROM tasks
LEFT JOIN user_tasks
ON tasks.task_id = user_tasks.task_id
WHERE tasks.task_milestone =
Add :
AND count(user_tasks.task_id) 0 in the where clause.
Greg Donald wrote:
Converting some MySQL code to work with Postgres here.
I have this query:
SELECT
tasks.task_id,
(tasks.task_duration * tasks.task_duration_type /
count(user_tasks.task_id)) as hours_allocated
FROM tasks
LEFT JOIN
Maybe try something like this :
SELECT
task_id,
CASE
WHEN task_count = '0'
THEN '0'::int4
ELSE (task_duration *
task_duration_type /
task_count) as hours_allocated
END
FROM
(SELECT
task_id,
task_duration,
task_duration_type,
count(user_tasks.task_id) as task_count
On Wed, 15 Sep 2004 12:55:24 -0400, Jean-Luc Lachance
[EMAIL PROTECTED] wrote:
Add :
AND count(user_tasks.task_id) 0 in the where clause.
I get the error:
aggregates not allowed in WHERE clause
--
Greg Donald
http://gdconsultants.com/
http://destiney.com/
---(end
Greg Donald wrote:
I get the error:
aggregates not allowed in WHERE clause
Try HAVING then.
--
Peter Eisentraut
http://developer.postgresql.org/~petere/
---(end of broadcast)---
TIP 5: Have you checked our extensive FAQ?
On Wed, Sep 15, 2004 at 12:23:55PM -0500, Greg Donald wrote:
On Wed, 15 Sep 2004 12:55:24 -0400, Jean-Luc Lachance
[EMAIL PROTECTED] wrote:
Add :
AND count(user_tasks.task_id) 0 in the where clause.
I get the error:
aggregates not allowed in WHERE clause
HAVING
Greg Donald [EMAIL PROTECTED] writes:
On Wed, 15 Sep 2004 12:55:24 -0400, Jean-Luc Lachance
[EMAIL PROTECTED] 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