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!
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 July 2026
Contest runs July 1 - 31. Complete challenges to climb the leaderboard!
Only the 31 daily challenges shown during this contest count toward points. Earlier dailies don't carry over.