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

Return the number of opportunities that are won (IsWon is true) and have a CloseDate within the current year. Use the THIS_YEAR SOQL date literal and a COUNT query.

Example 1:

Input: (query won opportunities closing in the current year) Output: 12 Explanation: There are 12 opportunities where IsWon is true and CloseDate falls within the current calendar year.

Example 2:

Input: (no won opportunities close in the current year) Output: 0 Explanation: Open or lost opportunities are excluded. Won opportunities from prior years are also excluded.

Example 3:

Input: (won opportunities exist but all in prior years) Output: 0 Explanation: Only the current calendar year counts. Won opportunities from other years are not included.
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 September 2026 (Sep 1–15)Sponsored by FLXBL

Contest runs September 1 - 15. Complete challenges to climb the leaderboard!

1st & 2nd: Salesforce certification exam voucher see all prizes

Only the 15 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