Posts

SOQL Interview questions - Part 2

   SOQL Intermediate level to Advanced level - Part 2 Link to Part 1:  https://sfdcinterviewpractice.blogspot.com/2025/11/soql-interview-questions.html 15: Fetch all active Accounts that have 2 or more Opportunities where StageName = 'Closed Won' SELECT AccountId, Account.Name, COUNT(Id) FROM Opportunity WHERE Account.Active__c = 'TRUE' AND StageName = 'ClosedWon'GROUP BY AccountId, Account.Name HAVING COUNT(Id) > 1 16: Contacts who have both a Case and an Opportunity related to their Account Find all Contacts where their parent Account has at least one Case and one Opportunity . SELECT Id, LastName FROM Contact WHERE AccountId IN (SELECT AccountId FROM Case) AND AccountId IN (SELECT AccountId FROM Opportunity) 17: Show Accounts with both open and closed Opportunities List Accounts that have at least one open and one closed Opportunity simultaneously. SELECT Name FROM Account WHERE Id IN (SELECT AccountId FROM Opportunity WHERE StageName = 'Closed Won...

SOQL Interview questions - Part 1

  SOQL Intermediate level to Advanced level - Part 1 Here are some simple to tricky interview questions asked on SOQL. if you are new to Salesforce development or SOQL, before going through below list of questions, please refer the provided link which explains about SOQL basic syntax and instructions on how to construct the query. https://developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/soql_sosl/sforce_api_calls_soql.htm 1: Accounts with no contacts SELECT Name FROM Account WHERE Id NOT IN (SELECT AccountId FROM Contact) 2: Contacts without Opportunities through Account SELECT Id,LastName FROM Contact WHERE AccountId NOT IN (SELECT AccountId FROM Opportunity) 3. Fetch Accounts created in the last 30 days that have at least one related Opportunity. SELECT Name FROM Account WHERE CreatedDate = LAST_N_DAYS:30 AND Id IN (SELECT AccountId FROM Opportunity) 4: Find Contacts that share the same Email address (show Name and Email). SELECT Email, COUNT(Id) FROM Contact WHERE Email ...