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...