我在以下的postgres中有一个查询
SELECT coalesce(dl.emp_id, um.id) id,
um.emp_name,
dl.project_id,
sum(dl.worked_hours)AS total
FROM tools_tracker.projects_master pm
FULL JOIN tools_tracker.daily_log dl ON dl.id=pm.id
FULL JOIN tools_tracker.users_master um ON dl.emp_id=um.id
AND dl.date BETWEEN '2019-04-23' AND '2019-04-26'
AND um.role='Development_Team'
GROUP BY COALESCE(dl.emp_id, um.id),
um.emp_name,
dl.project_id,
dl.worked_hours
ORDER BY um.emp_name ASC
哪个给出this作为结果输出
如何从id列中删除重复项?
请让我知道, 谢谢你。
答案 0 :(得分:1)
我认为您需要从dl.worked_hours
中删除GROUP BY
:
GROUP BY COALESCE(dl.emp_id, um.id),
um.emp_name,
dl.project_id