You need to sign in to do that
Don't have an account?
SOQL Query on Account Object
Hi Everyone,
I have 2 Custom fields as count__c and inte__c in Account Object. I want query for below credentials....
1) select count__c + inte__c from account;
2) select sum(count__c ) + sum(inte__c) from account;
How to achieve those things
Thanks & Best Regards,
Vignesh.B
I have 2 Custom fields as count__c and inte__c in Account Object. I want query for below credentials....
1) select count__c + inte__c from account;
2) select sum(count__c ) + sum(inte__c) from account;
How to achieve those things
Thanks & Best Regards,
Vignesh.B
/* If you want to sum of these field */
integer adding = count__c + inte__c ;
we have to do this like
AggregateResult[] groupedResults = [Select Sum(count__c ) total_count,Sum(inte__c)total_intec from Account];
Decimal total_intec = (Decimal)groupedResults[0].get('total_intec');
Decimal total_count = (Decimal)groupedResults[0].get('total_count');
Decimal total_sum = total_count + total_intec;
System.debug(total_sum);
Mark this as best answer if it helped you.
You can use the aggregate queries for this.
Points to remember--
1. Use aliases like 'countTotal' to get the value of the aggregate operation in the SOQL query.
2. to access the value from the aggregate result you have to use get() method as used above.
In case you find any other issue please mention.
If you find your Solution then mark this as the best answer.
Thanks and Regards
Suraj Tripathi.