我在网站上发现了一些其他线程,但这些解决方案似乎并不适用于我。
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, VrankGROUP BY的MySQL文档
更多推荐
WorkbenchJ
发布评论