Salesforce Menu

SOQL Examples

1. Query all the Contacts which are not related to any Account

SELECT Id FROM Contact WHERE AccountId = null

2. Query all the Accounts which do not have any Contacts under them

SELECT Id FROM Account WHERE Id NOT IN (SELECT AccountId FROM Contact WHERE AccountId != null)

3. Query all the Opportunities with a Close Date in the future

SELECT Id FROM Opportunity WHERE CloseDate > TODAY
Subscribe Now