WorkbenchJ

编程入门 行业动态 更新时间:2024-10-26 18:22:14
本文介绍了WorkbenchJ - 错误:在GROUP BY子句中不允许使用聚合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在网站上发现了一些其他线程,但这些解决方案似乎并不适用于我。

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

GROUP BY的MySQL文档

更多推荐

WorkbenchJ

本文发布于:2023-10-14 22:46:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1492434.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:WorkbenchJ

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!