Skip to content
StackDecode
IntermediateLesson 15 of 37

SOQL basics

The Salesforce Object Query Language.

sql
SELECT Id, Name, Amount, CloseDate
FROM Opportunity
WHERE StageName = 'Prospecting' AND Amount > 10000
ORDER BY CloseDate DESC
LIMIT 20
  • No SELECT *: you list fields.
  • Operators: =, !=, <, IN, LIKE '%corp%', NOT IN.
  • Date literals: TODAY, LAST_N_DAYS:30, THIS_QUARTER.
  • In Apex, use bind variables: WHERE Name = :accountName.
  • Run queries in the Developer Console Query Editor or VS Code.