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

Aggregate Aliasing No Longer Supported?
In testing my sandbox for the upcomming winter 12 release I have found that existing code has been broken (continues to work in production, coded exactly as it is in the sandbox).
It appears that aggregate functions can no longer be aliased according to the developer API documentation as found at:
http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_calls_soql_select_groupby_alias.htm
Provided are 3 SOQL queries demonstrating what I am experiencing. Two which should be run from the Sandbox and the third from production. I have indicated the outcome of each and the error received when applicable.
Failing from Sandbox (Invalid field Total_Cost__c
for (AggregateResult ar : [SELECT Sum(Total_Cost__c) Total_Cost__c FROM Service__c WHERE Quote__c in :listQuote GROUP BY Quote__c, Service_Category__c, Product__r.name]){ system.debug(ar.get('Total_Cost__c')); }
Success from Production
for (AggregateResult ar : [SELECT Sum(Total_Cost__c) Total_Cost__c FROM Service__c WHERE Quote__c in :listQuote GROUP BY Quote__c, Service_Category__c, Product__r.name]){ system.debug(ar.get('Total_Cost__c')); }
Success from Sandbox
for (AggregateResult ar : [SELECT Sum(Total_Cost__c) Total_Cost__c FROM Service__c WHERE Quote__c in :listQuote GROUP BY Quote__c, Service_Category__c, Product__r.name]){ system.debug(ar.get('expr0')); }
My questions are:
1. Are my results something that I am doing incorrectly?
2. Are we really losing the ability to alias aggregate functions in our SOQL?
3. Is there anywhere that this change (any any others, in this or future releases) is documented?
4. Are there any better ways of handling this change, besides ordering any/all aggregate functions and accessing them by their exprn position?
This may sound like an odd question, but on which 174 sandbox instance are you testing this?
cs7 is the current sandbox instance.
and what is the error you are receiving? Is it simply not returning any results? or is failing to run or compile?
Invalid field Total_Cost__c
Has anyone else been able to reproduce this in their own instances?