WorkbenchJ - 错误:在GROUP BY子句中不允许使用聚合 [英] WorkbenchJ - Error: aggregates not allowed in GROUP BY clause
问题描述
我在网站上发现了一些其他线程,但这些解决方案似乎并不适用于我。
I found a few other threads with this error message on the site but the solutions there did not seem to work for me.
这是我正在尝试的查询运行:
This is the query I am trying to run:
SELECT
o.name as Name,
o.vrank_tav__c as Vrank,
COUNT(c.enterprise_id) AS #_users_enterprise
FROM
(community_csv_james c JOIN
salesforce_data_opportunity o ON
c.enterprise_id = o.enterprise_id__c)
GROUP BY #_users_enterprise, Name, Vrank
ORDER BY #_users_enterprise DESC;
当我在SQL Workbench J上运行它时,出现以下错误:
When I run it on SQL Workbench J, I get the following error:
SELECT
o.name as Name,
o.vrank_tav__c as Vrank,
COUNT(c.enterprise_id) AS #_users_enterprise
FROM
(community_csv_james c JOIN
salesforce_data...
ERROR: aggregates not allowed in GROUP BY clause
我已经尝试了一些这样的变体,但是我推出了不同的错误消息。我该如何编写这个查询?
I've tried a few variations of this but I that promoted different error messages. How should I write this query?
谢谢!
Thanks!
推荐答案
您不应该包含聚合函数的结果())在你的分组中,这个计数将与一个独特的名字/ Vrank相关联,所以你只需要对这些分组进行分组,这就是为什么它给了你这个特定的错误。
You are not supposed to include the results from your aggregate function (your Count()) in your group by. The count is going to be associated with a distinct name/Vrank so you would only need to group on those. That's why it's giving you that specific error.
GROUP BY Name, Vrank
这篇关于WorkbenchJ - 错误:在GROUP BY子句中不允许使用聚合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!