You need to sign in to do that
Don't have an account?
RobJCowell
SOQLBuilder aggregate functions
So another SOQLbuilder question - why is SUM(Total_USD_Gross__c) the only field in the output SQL ?
companyquery = new SoqlBuilder() .selectx('Event_to_Deal__r.Client_Company__r.ID') .selectx('Event_to_Deal__r.Client_Company__r.Name') .selectsumx('Total_USD_Net__c') .selectsumx('Total_USD_Gross__c') .fromx('Event_Costs__c') .wherex(new SetCondition('Event_to_Deal__r.Client_Company__r.ID').inx(comps)) .groupByx('Event_to_Deal__r.Client_Company__r.ID') .toSOQL();
which yields the following SOQL
SELECT SUM(Total_USD_Gross__c) FROM Event_Costs__c WHERE Event_to_Deal__r.Client_Company__r.ID IN ('a0220000004aPRAAA2','a0220000006Fb7CAAS','a0220000004ZaYxAAK') GROUP BY Event_to_Deal__r.Client_Company__r.ID
Where are ID, Name and the other SUM ? The following manual SOQL works, and is the kind of thing I'm expecting SOQLbuilder to construct
SELECT Event_to_Deal__r.Client_Company__r.ID,Event_to_Deal__r.Client_Company__r.Name,SUM(Total_USD_Gross__c) Gross, SUM(total_USD_Net__c) Net FROM Event_Costs__c WHERE Event_to_Deal__r.Client_Company__r.ID IN ('a0220000004aPRAAA2','a0220000006Fb7CAAS','a0220000004ZaYxAAK') GROUP BY Event_to_Deal__r.Client_Company__r.ID,Event_to_Deal__r.Client_Company__r.Name
This is currently a limitation and needs to be addressed.
All Answers
This is currently a limitation and needs to be addressed.
It's strangely comforting to know it's not my poor usage then ;-)
I'll work around it for now, but I'm hoping to contribute a fix back to the community when I'm not under deadlines