Trigger to perform average or sum of child records on parent object based on product type

Job ID: 34154349

Budget: ₹600 – ₹1,500 INR

Trigger to perform average or sum of child records on parent object based on product type
Hi there.. I need help with a trigger which averages sub opportunities revenue field when product type is same else it sums the revenues at the parent (opprtunity object).
The trigger which I have written below only sums. Please help me so that based on the similar product types the revenue gets averages else sumed up.
Related categories: Salesforce App Development