You need to sign in to do that
Don't have an account?
Schuetzler
SOQL aggregate functions in Eclipse schema explorer
I am trying to test an aggregate query in the Schema Explorer. Unfortunately I can't seem to get it to work. When I run the following query, I got 7 results back:
SELECT Current_Annual_Maintenance_Value__c FROM Asset
However, when I run the following query I get nothing:
SELECT sum(Current_Annual_Maintenance_Value__c) FROM Asset
Can anyone explain how to correctly do an aggregate function in a query to work? I can't get anything to work when I try Count() either. I just get an empty column of data with expr0 as the column name.
What version of the API are you using? I think you have to be running 18 to have aggregate functions.
Edited to add: I just did a quick search and found this post in the community forum... It should address your topic quite well.
Aggregate Functions and API version
I saw that post, but unfortunately it doesn't answer my question. I'm not getting any errors when running the query. I just don't get any results.
How can I tell what version of the API I'm using in Schema Explorer? I assumed I was using 18 because I'm not getting any errors when running the aggregate function.
If you look at the Metadata tab, there should be a tag for API Version.
The metadata tab for Schema Explorer? I don't see that. The metadata for my Apex triggers and classes say I'm using API v18. That's my problem. Everything seems to work except that the query doesn't return anything.
I am seeing the same thing in Schema Explorer, however when I transfer the aggregate query to my class it works fine, so this must be an issue with Schema Explorer:
SELECT Program__r.Program_Code__c, AVG(X1a_weighted__c) FROM Evaluation__c WHERE Program__r.Evaluation_Team__c = 'Education B' and DateCompleted__c != null GROUP BY Program__r.Program_Code__c
results in two records with blank expr0 fields
Whereas,
SELECT Program__r.Program_Code__c, X1a_weighted__c FROM Evaluation__c WHERE Program__r.Evaluation_Team__c = 'Education B' and DateCompleted__c != null
results in four records with numeric values in each of the "X1a_weighted__c" (int) fields