You need to sign in to do that
Don't have an account?
Savi3
AggregateResult
Hi,
AggregateResult[] Ar = [Select sum(Field name ) total from contact ];
Double sum = 0;
if (Ar.size()>o){
String str = ' ' + Ar[0].get(''total);
sum = Double.valueof(str);
}
Can somone tell me why this total is using with sum(Fieldname)?? Similarly for Avg(fieldname) aver??
Thank you,
Sav3.
Its because of the alias you have given in the select statement. Alias is not mandatory
SOQL Query
AggregateResult[] Ar = [Select sum(Field name ) total from contact ];
SOQL Query Syntax in case of Aggregate field
AggregateResult[] Ar = [Select Aggregate field [Alias Name] from contact ];