function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Chandradeep MishraChandradeep Mishra 

SOQL Question group by and weight avg

Hi,

I have data like that

Xyz  4
Xyz  4
Xyz  4
Xyz  4
AB  5
AB  5
CD  6
YD  4

I want to group by and do sum only for the distinct rows and divide each with sum. for example :
            avg would
Xyz 4   
AB  5  
CD  6
YD  4
sum 19 and avg would be 
Xyz  4  4/19
Xyz  4  4/19
Xyz  4  4/19
Xyz  4  4/19
AB  5  5/19
AB  5  5/19
CD  6  6/19
YD  4  4/19

help me on this



 
Raza0195Raza0195
Hi Chandra Mishra,

It is not possible using group by SOQL query to sum unique records but we can do using custom logic.