Apex Trigger
trigger AccountTrigger on Account (before update) {
List<Opportunity> relatedOppList = [SELECT Id, Name, Amount FROM Opportunity
WHERE StageName='Closed Won' AND AccountId =: Trigger.new.get(0).id];
Decimal SumOfAmounts = 0;
for(Account ac : Trigger.new){
for(Opportunity opp: relatedOppList){
SumOfAmounts += opp.Amount;
}
ac.AnnualRevenue=SumOfAmounts;
}
}