我在Postgresql数据库中有两个表。它是一个帮助台数据库,它们是job_ticket
's和tech
's。我期望得到每种技术的平均第一响应。
我的查询如下所示。POSTGRESQL:错误:列“”必须出现在GROUP BY子句中或用于聚合函数中
SELECT
concat(tech.first_name, ' ', tech.last_name) AS Tech,
AVG((ticket.first_response_date::timestamptz AT TIME ZONE 'Australia/Sydney') - (ticket.report_date::timestamptz AT TIME ZONE 'Australia/Sydney')) AS First_Reply_Time
FROM
public.job_ticket ticket
INNER JOIN public.tech tech
ON ticket.client_id = tech.client_id;
但我不断收到错误ERROR: column "tech.first_name" must appear in the GROUP BY clause or be used in an aggregate function
什么是拉出来的技术和他们的第一个平均响应时间的最好方法?
你'AVG()'但没有'GROUP BY'。你不明白错误信息的哪一部分? –
请提供您想要的样品数据。 –
我得到了@GordonLinoff,但把这些语句放在'GROUP BY'中仍然给出了错误。 – michaelosmith