This question runs in a pre-configured Salesforce environment - no personal connection required.
Query all Opportunity records and return the average Amount, rounded to two decimal places using HALF_UP rounding. Only include Opportunities that have an Amount value. Use a SOQL aggregate function to compute the average in the database. Return 0 when no Opportunity has an Amount.
Examples:
Input: (no parameters, queries all Opportunities)
Output: 274500.00
Explanation: The value shown is illustrative. The method returns the true average Amount across all Opportunities rounded to two decimals
Input: (an org with no Opportunity Amounts)
Output: 0
Explanation: When the aggregate average is null the method returns 0
Apex Code Editor
Welcome to Lightning Challenge!
How It Works
- • Write your solution in the code editor
- • This challenge runs without connecting your own org
- • Submit to check if your solution passes
- • Use hints if you get stuck
Contest Alert
🏆 #CodeEveryDay October 2026 (Oct 16–31)Sponsored by FLXBL
Contest runs October 16 - 31. Complete challenges to climb the leaderboard!
Prizes 1 & 2: Salesforce certification exam voucher — won by random drawing, where every point is a ticket. see all prizes
Only the 16 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.