# Recalculate Account Opportunity Amount Total

**Type:** Apex trigger · **Difficulty:** Hard · **Object:** Opportunity · **Topics:** Opportunity, Account, Aggregate SOQL, Rollup, Bulkification

Practice this problem interactively (write and run your Apex trigger against realistic data): https://www.forcechallenges.com/problems/recalculate-account-opportunity-amount-total

## Problem

Whenever an Opportunity is inserted, updated, or deleted, recalculate the total Amount of Opportunities for every affected Account. Store the total in Account Opportunity_Amount_Total__c. Accounts with no Opportunities should have a total of zero. Use aggregate SOQL and update each Account only once.

## Constraints

Write bulk-safe trigger logic. Never run SOQL or DML inside a loop.

---
Source: ForceChallenges · last updated 2026-10-13
