You need to sign in to do that
Don't have an account?
Aggregate Results AVG not calculating correctly.
Hi All,
I have an aggregateResult query, which calculates the AVG of 'Segment' value (a field).
There are 4 records with Segment values as 100, 0, 0, 0. Ideally, the average should be 25 (100+0+0+0/4). But, the query is calculating the avegare as100. Since the values are 0s for 3 records, the query is not considering them. It is taking as 100/1= 100.
When the records have values, it is working fine. Ex: 100,50,50,100 - The avergare is correctly showing as 75.
How do I make it to display correct Average? Below is the query.
AggregateResult[] groupedResults = [Select Customer_Name__c,AVG(Segment__c) FROM Customer__c GROUP BY Customer_Name__c];
Please help. Thanks.
then this will show exact result now it grouping by name then calculating avg
Need average for each grouping of Customer Name.