Query { SELECT t.*, lc.category_name AS category_name, COUNT(c.comment_id) AS num_comments, uo.real_name AS opened_by_name, MIN(u.real_name) AS assigned_to_name, COUNT(DISTINCT ass.user_id) AS num_assigned, p.project_title, p.project_is_active, lst.status_name AS status_name, lt.tasktype_name AS task_type, lr.resolution_name FROM "flyspray_tasks" t LEFT JOIN "flyspray_projects" p ON t.project_id = p.project_id LEFT JOIN "flyspray_list_tasktype" lt ON t.task_type = lt.tasktype_id LEFT JOIN "flyspray_list_status" lst ON t.item_status = lst.status_id LEFT JOIN "flyspray_list_resolution" lr ON t.resolution_reason = lr.resolution_id LEFT JOIN "flyspray_list_category" lc ON t.product_category = lc.category_id LEFT JOIN "flyspray_comments" c ON t.task_id = c.task_id LEFT JOIN "flyspray_users" uo ON t.opened_by = uo.user_id LEFT JOIN "flyspray_assigned" ass ON t.task_id = ass.task_id LEFT JOIN "flyspray_users" u ON ass.user_id = u.user_id WHERE t.project_id = ? AND ( is_closed <> '1' ) GROUP BY t.task_id, lc.category_name, uo.real_name, p.project_title, p.project_is_active, lst.status_name, lt.tasktype_name,num_comments,t.task_id, lr.resolution_name, t.task_id, t.project_id, t.task_type, t.date_opened, t.opened_by, t.is_closed, t.date_closed, t.closed_by, t.closure_comment, t.item_summary, t.detailed_desc, t.item_status, t.resolution_reason, t.product_category, t.product_version, t.closedby_version, t.operating_system, t.task_severity, t.task_priority, t.last_edited_by, t.last_edited_time, t.percent_complete, t.mark_private, t.due_date, t.anon_email, t.task_token ORDER BY num_comments desc, t.task_id desc, t.task_id ASC} with params {2} Failed! (ERROR: aggregates not allowed in GROUP BY clause)