SOQL & SOSL

Easy SOQL & SOSL Practice Problems

33 free Salesforce Apex challenges · Full problem statements, best-practice notes, and step-by-step hints · Solve live on ApexArena

This guide walks through 33 foundational SOQL queries — filtering, ordering, and basic relationship queries. Each entry below includes the full problem statement, the governor-limit and best-practice constraints it's testing, and a numbered approach to solving it — then you can open the same problem in ApexArena's browser-based Apex editor and get instant pass/fail feedback against real test cases.

On this page
  1. 1. SOQL Aggregate Rollup
  2. 2. Date Literal Query: Leads Created in Last 30 Days
  3. 3. Retrieve Account Names and Industry
  4. 4. List All Closed Won Opportunities with Amounts
  5. 5. Five Most Recently Created Leads
  6. 6. Average Amount of Closed Won Opportunities
  7. 7. Opportunities Closing in the Next 7 Days
  8. 8. Opportunities with a Close Date in the Current Month
  9. 9. Total Number of Leads in Each Lead Source Category
  10. 10. Accounts with Billing Postal Code Starting with "9"
  11. 11. Opportunities in Negotiation Stage with Amount > $100,000
  12. 12. Opportunities Closing in the Next 14 Days (Sorted by Close Date)
  13. 13. Opportunities Created by a Specific User
  14. 14. SOQL Child-to-Parent: Contact with Account Name
  15. 15. SOQL Child-to-Parent: Opportunity with Account Industry
  16. 16. SOQL Child-to-Parent: Contact with Account Billing Address
  17. 17. SOQL Child-to-Parent: Open Cases with Account Name
  18. 18. SOQL Parent-to-Child: Account with Contacts Subquery
  19. 19. SOQL Parent-to-Child: Account with Open Opportunities
  20. 20. SOQL: Get All Accounts
  21. 21. SOQL: Filter Accounts by Industry
  22. 22. SOQL: Retrieve Top 5 Accounts
  23. 23. SOQL: Sort Accounts by CreatedDate Descending
  24. 24. SOQL: Accounts Whose Name Starts With "A"
  25. 25. SOQL: Contacts That Have an Email Address
  26. 26. SOQL: Opportunities with Amount Greater Than 50,000
  27. 27. SOQL: Retrieve All Closed Won Opportunities
  28. 28. SOQL: Contacts Created Today Using Date Literal
  29. 29. SOQL: Count Total Number of Accounts
  30. 30. SOQL: Parent-to-Child Subquery With LIMIT
  31. 31. SOQL: 10 Most Recently Created Leads
  32. 32. SOQL: Opportunities Closing This Month
  33. 33. SOQL: Filter Accounts Using the IN Operator
Easy SOQLGovernor

1. SOQL Aggregate Rollup

Problem #8 · Salesforce Apex Coding Challenge

Problem Statement

Write a SOQL query using aggregate functions to produce a summary report of Opportunity records grouped by StageName.

For each stage, return the count, total amount, and average amount.

Expected Output Format

Stage         | Count | Total      | Average
Prospecting   |  24   | 1,200,000  | 50,000
Closed Won    |  18   | 4,500,000  | 250,000
Approach
  • 1Use SUM(Amount) totalAmt and AVG(Amount) avgAmt in the SELECT clause.
  • 2Access results with: (Decimal) result.get('totalAmt')
  • 3You can alias each aggregate expression for cleaner access in Apex.
Easy SOQL

2. Date Literal Query: Leads Created in Last 30 Days

Problem #86 · Salesforce Apex Coding Challenge

Problem Statement

Write a method that returns all Lead records created within the last 30 days, ordered newest-first.

Method Signature

public static List<Lead> getRecentLeads()

Key Concept — Date Literals

SOQL date literals let you write time-relative filters without hardcoding dates. They are written without quotes and some accept a numeric suffix (:N):

WHERE CreatedDate >= LAST_N_DAYS:30

Common date literals:

  • TODAY, YESTERDAY, TOMORROW
  • THIS_WEEK, LAST_WEEK, NEXT_WEEK
  • LAST_N_DAYS:n — the past n days (including today)
  • NEXT_N_DAYS:n — the next n days
  • THIS_MONTH, LAST_MONTH, NEXT_MONTH

Constraints

  • Use a date literal — not a hardcoded date string
  • Order by CreatedDate DESC (newest first)
  • Return at least Id, FirstName, LastName, CreatedDate
Approach
  • 1Date literals go directly in WHERE without quotes: WHERE CreatedDate >= LAST_N_DAYS:30
  • 2You can also use = LAST_N_DAYS:30 — it includes all records from the rolling 30-day window.
  • 3ORDER BY CreatedDate DESC puts the most recently created lead first.
Easy SOQL

3. Retrieve Account Names and Industry

Problem #107 · Salesforce Apex Coding Challenge

Problem Statement

Write a SOQL query inside getAccountsWithIndustry() that retrieves all Account Name and Industry fields, ordered alphabetically by Name.

Requirements

  • SELECT Name and Industry
  • FROM Account
  • ORDER BY Name ASC
  • LIMIT 200
Approach
  • 1SELECT Name, Industry FROM Account is the core query.
  • 2Add after FROM Account to respect field-level security.
  • 3ORDER BY Name ASC sorts results alphabetically.
Easy SOQL

4. List All Closed Won Opportunities with Amounts

Problem #110 · Salesforce Apex Coding Challenge

Problem Statement

List all Closed Won Opportunities with their Name, Amount, and CloseDate, sorted by highest Amount first.

Requirements

  • WHERE StageName = 'Closed Won'
  • SELECT Name, Amount, CloseDate, AccountId
  • ORDER BY Amount DESC
Approach
  • 1StageName = 'Closed Won' — exact stage value, casing matters.
  • 2ORDER BY Amount DESC puts the largest deals first.
  • 3Include CloseDate in SELECT to give callers the win date.
Easy SOQL

5. Five Most Recently Created Leads

Problem #111 · Salesforce Apex Coding Challenge

Problem Statement

Write a SOQL query that retrieves the five most recently created Leads, ordered from newest to oldest.

Requirements

  • SELECT Id, FirstName, LastName, Email, Company, CreatedDate
  • FROM Lead
  • ORDER BY CreatedDate DESC
  • LIMIT 5
Approach
  • 1CreatedDate is a system field on every Salesforce object.
  • 2ORDER BY CreatedDate DESC puts the newest record first.
  • 3LIMIT 5 caps the result at five records.
Easy SOQLAggregate

6. Average Amount of Closed Won Opportunities

Problem #113 · Salesforce Apex Coding Challenge

Problem Statement

Compute and return the average Amount of all Closed Won Opportunities as a Decimal. Return 0 if no records exist.

Requirements

  • Use AVG(Amount) avgAmt
  • WHERE StageName = 'Closed Won'
  • Access result: (Decimal) results[0].get('avgAmt')
  • Guard: return 0 if results list is empty
Approach
  • 1SELECT AVG(Amount) avgAmt FROM Opportunity WHERE StageName = 'Closed Won'.
  • 2Access with results[0].get('avgAmt') — the alias must match.
  • 3Guard against empty results before accessing index 0.
Easy SOQLDate Literals

7. Opportunities Closing in the Next 7 Days

Problem #114 · Salesforce Apex Coding Challenge

Problem Statement

Return all Opportunities whose CloseDate falls within the next 7 calendar days, ordered soonest-first.

Key Concept — Date Literals

NEXT_N_DAYS:7 matches any date from tomorrow through 7 days from today (inclusive). No Apex date arithmetic is needed.

Requirements

  • WHERE CloseDate = NEXT_N_DAYS:7
  • ORDER BY CloseDate ASC
Approach
  • 1NEXT_N_DAYS:7 is a SOQL date literal — no Apex Date.today().addDays(7) needed.
  • 2ORDER BY CloseDate ASC shows deals that need attention soonest.
  • 3enforces FLS.
Easy SOQLDate Literals

8. Opportunities with a Close Date in the Current Month

Problem #117 · Salesforce Apex Coding Challenge

Problem Statement

Return all Opportunities whose CloseDate falls within the current calendar month, ordered from earliest to latest close date.

Key Concept

THIS_MONTH covers the entire current month — first day through last day — regardless of today's date.

Requirements

  • WHERE CloseDate = THIS_MONTH
  • ORDER BY CloseDate ASC
Approach
  • 1THIS_MONTH matches any CloseDate in the current calendar month.
  • 2No date arithmetic needed — just WHERE CloseDate = THIS_MONTH.
  • 3ORDER BY CloseDate ASC gives a chronological view of the month.
Easy SOQLAggregate

9. Total Number of Leads in Each Lead Source Category

Problem #120 · Salesforce Apex Coding Challenge

Problem Statement

Aggregate the Lead object to find the total number of Leads in each Lead Source category, ordered from the most to the least common source.

Requirements

  • SELECT LeadSource, COUNT(Id) total
  • FROM Lead
  • GROUP BY LeadSource
  • ORDER BY COUNT(Id) DESC
Approach
  • 1GROUP BY LeadSource partitions Leads into per-source buckets.
  • 2COUNT(Id) total counts leads per bucket; access with ar.get('total').
  • 3ORDER BY COUNT(Id) DESC puts the most common source first.
Easy SOQL

10. Accounts with Billing Postal Code Starting with "9"

Problem #121 · Salesforce Apex Coding Challenge

Problem Statement

Retrieve all Accounts whose Billing Postal Code starts with the digit "9".

Key Concept — LIKE Operator

LIKE '9%' in SOQL matches any string beginning with "9". The % wildcard matches zero or more characters.

Requirements

  • WHERE BillingPostalCode LIKE '9%'
  • SELECT Id, Name, BillingPostalCode
  • ORDER BY Name ASC
Approach
  • 1LIKE '9%' matches postal codes starting with 9: '9', '90210', '94105', etc.
  • 2The LIKE operator is case-insensitive in SOQL.
  • 3SELECT BillingPostalCode so callers can see what matched.
Easy SOQL

11. Opportunities in Negotiation Stage with Amount > $100,000

Problem #123 · Salesforce Apex Coding Challenge

Problem Statement

Retrieve Opportunities in the "Negotiation" stage that also have an Amount greater than $100,000.

Requirements

  • WHERE StageName = 'Negotiation' AND Amount > 100000
  • SELECT Id, Name, Amount, StageName, AccountId
  • ORDER BY Amount DESC
Approach
  • 1Combine: WHERE StageName = 'Negotiation' AND Amount > 100000.
  • 2Amount is numeric in SOQL — no $ symbol or commas.
  • 3ORDER BY Amount DESC surfaces the highest-value negotiations first.
Easy SOQLDate Literals

12. Opportunities Closing in the Next 14 Days (Sorted by Close Date)

Problem #125 · Salesforce Apex Coding Challenge

Problem Statement

List all open Opportunities whose CloseDate is within the next 14 days, sorted soonest-to-close first.

Requirements

  • WHERE CloseDate <= NEXT_N_DAYS:14
  • AND IsClosed = false
  • ORDER BY CloseDate ASC
Approach
  • 1NEXT_N_DAYS:14 is a date literal — CloseDate <= NEXT_N_DAYS:14 covers the next 14 days.
  • 2AND IsClosed = false excludes already-closed deals.
  • 3ORDER BY CloseDate ASC shows deals needing attention soonest.
Easy SOQL

13. Opportunities Created by a Specific User

Problem #132 · Salesforce Apex Coding Challenge

Problem Statement

Return all Opportunities created by a specific user, identified by their Salesforce User Id, ordered most-recent first.

Requirements

  • WHERE CreatedById = :userId
  • Method signature: getOpportunitiesCreatedByUser(Id userId)
  • SELECT Id, Name, Amount, StageName, CreatedDate
  • ORDER BY CreatedDate DESC
Approach
  • 1CreatedById is a standard system field on every Salesforce SObject.
  • 2Bind the parameter: WHERE CreatedById = :userId (colon required).
  • 3ORDER BY CreatedDate DESC shows most recently created opportunities first.
Easy SOQLChild-to-Parent

14. SOQL Child-to-Parent: Contact with Account Name

Problem #184 · Salesforce Apex Coding Challenge

Problem Statement

Write a child-to-parent SOQL query that retrieves a list of Contacts along with the name of each Contact's parent Account.

Requirements

  • SELECT: Id, FirstName, LastName, Email, Account.Name
  • FROM Contact
  • ORDER BY LastName ASC, LIMIT 20

Key Concept

Use dot notation (Account.Name) to traverse the relationship from child (Contact) to parent (Account).

Approach
  • 1Use dot notation: Account.Name in the SELECT clause
  • 2Query FROM Contact, not FROM Account
  • 3ORDER BY LastName ASC LIMIT 20
Easy SOQLChild-to-Parent

15. SOQL Child-to-Parent: Opportunity with Account Industry

Problem #185 · Salesforce Apex Coding Challenge

Problem Statement

Write a child-to-parent SOQL query that retrieves open Opportunities along with the Industry of their parent Account.

Requirements

  • SELECT: Id, Name, StageName, CloseDate, Amount, Account.Industry
  • FROM Opportunity WHERE IsClosed = false
  • ORDER BY CloseDate ASC, LIMIT 20
Approach
  • 1Use Account.Industry in your SELECT clause
  • 2Filter with WHERE IsClosed = false
  • 3ORDER BY CloseDate ASC to see soonest closings first
Easy SOQLChild-to-Parent

16. SOQL Child-to-Parent: Contact with Account Billing Address

Problem #186 · Salesforce Apex Coding Challenge

Problem Statement

Retrieve Contacts along with their parent Account's billing address fields (City, State, Country) using child-to-parent SOQL.

Requirements

  • SELECT: Id, FirstName, LastName, Email, Account.BillingCity, Account.BillingState, Account.BillingCountry
  • FROM Contact WHERE Account.BillingCity != null
  • ORDER BY Account.BillingCountry ASC, LIMIT 20
Approach
  • 1You can filter on related fields: WHERE Account.BillingCity != null
  • 2Multiple parent fields: Account.BillingCity, Account.BillingState, Account.BillingCountry
  • 3ORDER BY a parent field: Account.BillingCountry ASC
Easy SOQLChild-to-Parent

17. SOQL Child-to-Parent: Open Cases with Account Name

Problem #187 · Salesforce Apex Coding Challenge

Problem Statement

Write a child-to-parent SOQL query that retrieves open Cases with their parent Account name.

Requirements

  • SELECT: Id, CaseNumber, Subject, Status, Priority, Account.Name
  • FROM Case WHERE Status != 'Closed'
  • ORDER BY Priority ASC, LIMIT 20
Approach
  • 1Use Account.Name in the SELECT to get the parent account's name
  • 2Filter: WHERE Status != 'Closed'
  • 3ORDER BY Priority ASC

Halfway there — solve them live

Every problem above runs in a real in-browser Apex editor with instant pass/fail feedback and best-practice linting. No Salesforce org needed.

Create Free Account →
Easy SOQLParent-to-Child

18. SOQL Parent-to-Child: Account with Contacts Subquery

Problem #194 · Salesforce Apex Coding Challenge

Problem Statement

Write a parent-to-child SOQL query that retrieves Accounts together with a list of their related Contacts using a subquery.

Requirements

  • SELECT: Id, Name, Phone, Website, plus a subquery: (SELECT Id, FirstName, LastName, Email FROM Contacts)
  • FROM Account
  • ORDER BY Name ASC, LIMIT 10

Key Concept

Parent-to-child uses a subquery in parentheses: (SELECT ... FROM Contacts). Note the plural relationship name Contacts, not Contact.

Approach
  • 1Parent-to-child uses a subquery in parentheses: (SELECT ... FROM Contacts)
  • 2Use the PLURAL relationship name: Contacts (not Contact)
  • 3The subquery goes inside the outer SELECT, not in a WHERE clause
Easy SOQLParent-to-Child

19. SOQL Parent-to-Child: Account with Open Opportunities

Problem #195 · Salesforce Apex Coding Challenge

Problem Statement

Retrieve Accounts with a subquery for their open Opportunities. The subquery should filter and order the child records.

Requirements

  • Subquery: (SELECT Id, Name, StageName, Amount, CloseDate FROM Opportunities WHERE IsClosed = false ORDER BY CloseDate ASC)
  • Outer: FROM Account, ORDER BY Name ASC, LIMIT 10
Approach
  • 1Subquery relationship name: Opportunities (plural)
  • 2Add WHERE clause inside the subquery: WHERE IsClosed = false
  • 3ORDER BY inside the subquery sorts the child records independently
Easy SOQL

20. SOQL: Get All Accounts

Problem #250 · Salesforce Apex Coding Challenge

Problem Statement

Inside SOQLPracticeService, implement getAllAccounts() that returns every Account with its Id, Name, and Industry fields.

Requirements

  • SELECT Id, Name, Industry
  • FROM Account
  • Return type: List<Account>
Approach
  • 1The simplest SOQL query has no WHERE clause — it returns all rows.
  • 2Always include Id so callers can reference each record.
  • 3Return the query result directly: return [SELECT … FROM Account];
Easy SOQL

21. SOQL: Filter Accounts by Industry

Problem #251 · Salesforce Apex Coding Challenge

Problem Statement

Implement getAccountsByIndustry(String industryName) that returns all Accounts whose Industry matches the given parameter.

Requirements

  • SELECT Id, Name, Industry
  • FROM Account
  • WHERE Industry = :industryName (bind variable)
Approach
  • 1Use a colon (:) to bind an Apex variable into SOQL: WHERE Industry = :industryName.
  • 2Bind variables prevent SOQL injection — never concatenate strings into a query.
  • 3The parameter name in the bind must match exactly the Apex variable name.
Easy SOQL

22. SOQL: Retrieve Top 5 Accounts

Problem #252 · Salesforce Apex Coding Challenge

Problem Statement

Implement getTopAccounts() that returns only the first 5 Account records with Id and Name.

Requirements

  • SELECT Id, Name
  • FROM Account
  • LIMIT 5
Approach
  • 1LIMIT n caps the result set — use LIMIT 5 to get at most 5 records.
  • 2Without ORDER BY the order is undefined; add ORDER BY Name if you need determinism.
  • 3LIMIT must be the last clause in the query (after ORDER BY).
Easy SOQL

23. SOQL: Sort Accounts by CreatedDate Descending

Problem #253 · Salesforce Apex Coding Challenge

Problem Statement

Implement getAccountsSorted() that returns all Accounts sorted from newest to oldest by CreatedDate.

Requirements

  • SELECT Id, Name, CreatedDate
  • FROM Account
  • ORDER BY CreatedDate DESC
Approach
  • 1ORDER BY field DESC returns largest/newest values first.
  • 2CreatedDate is a system field automatically set on every record.
  • 3You can chain multiple sort fields: ORDER BY CreatedDate DESC, Name ASC.
Easy SOQL

24. SOQL: Accounts Whose Name Starts With "A"

Problem #254 · Salesforce Apex Coding Challenge

Problem Statement

Implement getAccountsStartsWithA() that returns all Accounts whose Name begins with the letter "A".

Requirements

  • SELECT Id, Name
  • WHERE Name LIKE 'A%'
  • The % wildcard matches any suffix
Approach
  • 1LIKE 'A%' matches any string starting with A followed by any characters.
  • 2% is the multi-character wildcard in SOQL LIKE (same as SQL).
  • 3LIKE is case-insensitive in SOQL, so 'A%' also matches 'apex', 'ACME', etc.
Easy SOQL

25. SOQL: Contacts That Have an Email Address

Problem #255 · Salesforce Apex Coding Challenge

Problem Statement

Implement getContactsWithEmail() that returns all Contacts where the Email field is populated (not null).

Requirements

  • SELECT Id, FirstName, LastName, Email
  • FROM Contact
  • WHERE Email != null
Approach
  • 1Use WHERE Email != null to exclude contacts with no email.
  • 2In SOQL, != null and <> null are both valid null-check operators.
  • 3Always SELECT the fields you intend to display or process.
Easy SOQL

26. SOQL: Opportunities with Amount Greater Than 50,000

Problem #256 · Salesforce Apex Coding Challenge

Problem Statement

Implement getHighValueOpportunities() that returns all Opportunities with Amount greater than 50,000.

Requirements

  • SELECT Id, Name, Amount
  • FROM Opportunity
  • WHERE Amount > 50000
Approach
  • 1Use the > operator for numeric comparisons in SOQL.
  • 2Amount is a Currency field — no quotes needed around the numeric value.
  • 3Records where Amount is null will not satisfy Amount > 50000.
Easy SOQL

27. SOQL: Retrieve All Closed Won Opportunities

Problem #257 · Salesforce Apex Coding Challenge

Problem Statement

Implement getClosedWonOpps() that returns all Opportunities in the "Closed Won" stage.

Requirements

  • SELECT Id, Name, StageName
  • FROM Opportunity
  • WHERE StageName = 'Closed Won'
Approach
  • 1The stage value is 'Closed Won' — exact casing matters in SOQL string comparisons.
  • 2StageName is a picklist field; its API value must match exactly.
  • 3String literals in SOQL use single quotes, not double quotes.
Easy SOQL

28. SOQL: Contacts Created Today Using Date Literal

Problem #258 · Salesforce Apex Coding Challenge

Problem Statement

Implement getTodayContacts() that returns all Contacts created today using a SOQL date literal.

Requirements

  • SELECT Id, Name
  • FROM Contact
  • WHERE CreatedDate = TODAY

SOQL Date Literals

Date literals like TODAY, YESTERDAY, THIS_WEEK, LAST_N_DAYS:n are evaluated at query time in the user's timezone.

Approach
  • 1TODAY is a SOQL date literal — no quotes, no bind variable needed.
  • 2CreatedDate is a DateTime field; using = TODAY matches the entire current day.
  • 3Other useful literals: YESTERDAY, THIS_WEEK, THIS_MONTH, LAST_N_DAYS:7.
Easy SOQLAggregate

29. SOQL: Count Total Number of Accounts

Problem #259 · Salesforce Apex Coding Challenge

Problem Statement

Implement getAccountCount() that returns the total number of Account records as an Integer.

Requirements

  • Use SELECT COUNT() — no field name inside COUNT()
  • FROM Account
  • Return type: Integer
  • A COUNT() query returns an Integer directly, not a list
Approach
  • 1SELECT COUNT() (no field name) returns an Integer directly — no AggregateResult needed.
  • 2This is the only SOQL query form that returns a scalar Integer, not a List.
  • 3Do not confuse with COUNT(Id), which requires AggregateResult[] and GROUP BY.
Easy SOQLSubquery

30. SOQL: Parent-to-Child Subquery With LIMIT

Problem #272 · Salesforce Apex Coding Challenge

Problem Statement

Implement getAccountsWithLimitedContacts() that fetches each Account with at most 3 of its Contacts.

Requirements

  • Outer: SELECT Id, Name FROM Account
  • Subquery: (SELECT Id, LastName FROM Contacts LIMIT 3)
Approach
  • 1LIMIT inside a subquery caps child records per parent, not total.
  • 2Combine with ORDER BY inside the subquery to get the "first 3" by a meaningful field.
  • 3LIMIT 3 keeps the result set small and avoids heap-size issues.
Easy SOQL

31. SOQL: 10 Most Recently Created Leads

Problem #275 · Salesforce Apex Coding Challenge

Problem Statement

Implement getRecentLeads() that returns the 10 most recently created Leads with their Name and Company.

Requirements

  • SELECT Id, Name, Company
  • FROM Lead
  • ORDER BY CreatedDate DESC
  • LIMIT 10
Approach
  • 1Combine ORDER BY CreatedDate DESC with LIMIT 10 to get the freshest 10 records.
  • 2Always put LIMIT after ORDER BY (it is the last clause).
  • 3Company is a required field on Lead in standard Salesforce orgs.
Easy SOQL

32. SOQL: Opportunities Closing This Month

Problem #277 · Salesforce Apex Coding Challenge

Problem Statement

Implement getThisMonthOpportunities() that returns all Opportunities whose CloseDate falls within the current calendar month.

Requirements

  • SELECT Id, Name, CloseDate
  • FROM Opportunity
  • WHERE CloseDate = THIS_MONTH

Common Date Literals

  • TODAY, YESTERDAY
  • THIS_WEEK, LAST_WEEK, NEXT_WEEK
  • THIS_MONTH, LAST_MONTH, NEXT_MONTH
  • LAST_N_DAYS:n, NEXT_N_DAYS:n
Approach
  • 1THIS_MONTH covers from the 1st to the last day of the current month.
  • 2CloseDate is a Date field on Opportunity (not DateTime), so THIS_MONTH works directly.
  • 3Date literals are evaluated relative to the running user's timezone.
Easy SOQL

33. SOQL: Filter Accounts Using the IN Operator

Problem #278 · Salesforce Apex Coding Challenge

Problem Statement

Implement getAccountsByIndustries() that returns Accounts in the Banking, IT, or Healthcare industries using the IN operator.

Requirements

  • SELECT Id, Name, Industry
  • FROM Account
  • WHERE Industry IN ('Banking', 'IT', 'Healthcare')

IN Operator

IN is equivalent to multiple OR conditions. It accepts a comma-separated list of values enclosed in parentheses.

Approach
  • 1IN ('v1','v2','v3') is a concise alternative to three OR conditions.
  • 2You can also bind an Apex Set or List: WHERE Industry IN :mySet.
  • 3IN is case-sensitive for string picklist values — match the API label exactly.

Practice All 33 Problems Free

Write and run real Apex code right in your browser — instant pass/fail feedback, best-practice linting, and governor limit monitoring. No Salesforce org needed.

Create Free Account → Explore All Problems
More Practice Topics
About ApexArena

ApexArena is a free, browser-based Salesforce Apex coding practice platform covering every major topic tested on the Salesforce Platform Developer I (PD1) and Platform Developer II (PD2) certification exams. All problems run directly in your browser with instant pass/fail feedback, best-practice linting (SOQL in loops, DML in loops, empty catch blocks), and governor limit monitoring — no Salesforce Developer Edition org required.

Related tutorials: Apex Triggers · SOQL · Batch Apex · Interview Q&A · Governor Limits