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

Query all accounts and return a Map where the key is the Account Type (such as Customer, Prospect, Partner) and the value is the sum of AnnualRevenue for accounts of that type. Only include accounts with non-null Type and non-null AnnualRevenue values. Use aggregate SOQL queries with GROUP BY to efficiently calculate sums per type.

Examples:

Output: {'Customer' => 450000000.00, 'Prospect' => 125000000.00} Explanation: Sums the AnnualRevenue for all Customer accounts and all Prospect accounts Output: {'Partner' => 75000000.00} Explanation: Only Partner accounts exist with non-null revenue in the org
Apex Code Editor

Welcome to Lightning Challenge!

Create an Account

Sign up to track your progress, earn points, and compete with others. Your solutions will be saved automatically.

Create account

How It Works

  • • Write your solution in the code editor
  • • Connect your Salesforce org to test
  • • Submit to check if your solution passes
  • • Use hints if you get stuck

Note

You can test your code by connecting to Salesforce, but to save your progress and earn points, you'll need to create an account. Your solutions and achievements will be tracked automatically once you're logged in.