This question runs in a pre-configured Salesforce environment - no personal connection required.

Calculate Total Revenue by Industry

Write a method that calculates the total AnnualRevenue for each Industry from the Account object. Return a Map where the key is the Industry name (String) and the value is the total revenue (Decimal) for that industry. Only include industries where at least one account has a non-null AnnualRevenue value.

Method Signature:

public static Map<String, Decimal> getRevenueByIndustry()

Examples:

Input: No parameters Output: {'Technology' => 45000000, 'Finance' => 30000000, 'Healthcare' => 15000000} Explanation: The Technology industry has a total of 45 million in revenue across all accounts, Finance has 30 million, and Healthcare has 15 million Input: No parameters Output: {'Manufacturing' => 80000000} Explanation: If only Manufacturing accounts have non-null revenue values, only Manufacturing appears in the result with the sum of all Manufacturing account revenues
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.

Wally can't hear you

Please sign in to access the AI Assistant

Sign In