You need to sign in to do that
Don't have an account?
Chanagan Sakulteera
How to fix this error "Illegal assignment from LIST<AggregateResult>".
Hi all,
I want to know how to fix this error "Illegal assignment from LIST<AggregateResult> to SOBJECT:Product_Service__c"
thsi is a code
interFlight = [select sum(Total_Cost__c) from Product_Service__c where Product_Service_Type__c = 'Air Ticket - International' and id =: productId];
Many thank in advance :)))
I want to know how to fix this error "Illegal assignment from LIST<AggregateResult> to SOBJECT:Product_Service__c"
thsi is a code
interFlight = [select sum(Total_Cost__c) from Product_Service__c where Product_Service_Type__c = 'Air Ticket - International' and id =: productId];
Many thank in advance :)))
Use "Aggregate Functions".
Check the below link.
http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_SOQL_agg_fns.htm
Can you please tell me the type of variable "interFlight"
The query you have has aggregated function sum(Total_Cost__c).
Here is the sample code:
AggregateResult[] groupedResults
= [SELECT AVG(Amount)aver FROM Opportunity];
Object avgAmount = groupedResults[0].get('aver');
Thanks,
Pratik