You need to sign in to do that
Don't have an account?

SOQL GROUP BY Issue
I'm having some trouble returning data from this SOQL query:
SELECT CALENDAR_YEAR(CreatedDate), SUM(Amount) FROM Opportunity GROUP BY CALENDAR_YEAR(CreatedDate)
It returns absolutly nothing even though I have multiple opportunities with amounts.
Here is the full method:
@RemoteAction global Static List<sObject> loadOppsByMonth(){ return [SELECT CALENDAR_MONTH(CreatedDate), SUM(Amount), SUM(ExpectedRevenue) FROM Opportunity GROUP BY CALENDAR_MONTH(CreatedDate)]; }
Is my return datatype wrong? Should I be looping through the data returned from this query?
Full context of the situation: I'm trying to write a query that provides summerized data to a LineChart using the Google Charting API
Not sure of the need to make this global or @remoteaction, I have used google chart api in visualforce with list data returned from apex classes without issue. In any case, try using the list returned from this.
The problem is you are working with an aggregateresult, not an sobject. If you are not comfortable working with aggregateresults, you can always put them into a wrapper class to iterate through in visualforce.
Hope this helps.
All Answers
Not sure of the need to make this global or @remoteaction, I have used google chart api in visualforce with list data returned from apex classes without issue. In any case, try using the list returned from this.
The problem is you are working with an aggregateresult, not an sobject. If you are not comfortable working with aggregateresults, you can always put them into a wrapper class to iterate through in visualforce.
Hope this helps.