function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
mohimohi 

Soql query:

Hi

list<navpa__Fundraising__c> firstclosing=[select navpa__Fund_Manager__c,navpa__Investment_Likely_Amount_USD_mn__c ,Probability__c,sum(navpa__Investment_Likely_Amount_USD_mn__c) total,Probability_Weighted__c,navpa__Closing__c from navpa__Fundraising__c where (navpa__Institution_Name__c=:uidd and navpa__Closing__c='1st Closing') Group By  navpa__Closing__c];

 

Error message:Field must be grouped or aggregated: navpa__Fund_Manager__c at line,if i remove the sum function& group by clause it brinhgs record, as i use aggregate function it shows error plz specify.

WesNolte__cWesNolte__c

Hey

 

When using aggregate functions in SOQL the query result type is Aggregate result i.e.

 

List<aggregateResult> results = [select navpa__Fund_Manager__c,navpa__Investment_Likely_Amount_USD_mn__c ,Probability__c,sum(navpa__Investment_Likely_Amount_USD_mn__c) total,Probability_Weighted__c,navpa__Closing__c from navpa__Fundraising__c where (navpa__Institution_Name__c=:uidd and navpa__Closing__c='1st Closing') Group By  navpa__Closing__c];

 

Also - if you think about it - you're grouping results so individual record field values can't be returned i.e. using the group by you're telling the query to mash the results together into groups, but the navpa_Fund_Manager__c field isn't grouped or aggregated so it's not sure how to present the information.

 

You can read more here: http://blog.jeffdouglas.com/2010/04/12/using-aggregateresult-in-salesforce-com-soql/

 

Wes

tantotanto

When you are using aggregate functions in SOQL all fields selected must either be grouped or used in an aggregate function. More info is available on aggregate functions in the Web Service's API doc - http://www.salesforce.com/us/developer/docs/api/index.htm