WorkbenchJ - Error: aggregates not allowed in GROUP BY clause
<p>I found a few other threads with this error message on the site but the solutions there did not seem to work for me.</p>

<p>This is the query I am trying to run:</p>

<pre><code>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;
</code></pre>

<p>When I run it on SQL Workbench J, I get the following error:</p>

<pre><code>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
</code></pre>

<p>I've tried a few variations of this but I that promoted different error messages. How should I write this query?</p>

<p>Thanks!</p>