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

Write a method that queries accounts filtered by account type and country. The method should return accounts that match both the specified type AND country, with their Name, AnnualRevenue, and Rating fields, sorted by AnnualRevenue in descending order.

Examples

Input: accountType = 'Customer', country = 'USA' Output: [ {'Name': 'TechFlow Solutions', 'AnnualRevenue': 45000000, 'Rating': 'Hot'}, {'Name': 'Cloud Code Academy', 'AnnualRevenue': 25000000, 'Rating': 'Warm'}, {'Name': 'SafeHarbor Insurance', 'AnnualRevenue': 12500000, 'Rating': 'Hot'} ] Explanation: Returns all accounts where Type = 'Customer' AND BillingCountry = 'USA', sorted by revenue DESC Input: accountType = 'Prospect', country = 'Canada' Output: [ {'Name': 'EcoLogic Solutions', 'AnnualRevenue': 890000, 'Rating': 'Cold'} ] Explanation: Returns the single matching account Input: accountType = 'Customer', country = 'Antarctica' Output: [] Explanation: Returns empty list when no accounts match both criteria Input: accountType = null, country = 'USA' Output: [] Explanation: Returns empty list when either parameter is null
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.