Salesforce Certified Platform Developer II — Question 65
A company has a custom object, Order__c, that has a custom picklist field, Status__c, with values of `˜New', `˜In Progress', or `˜Fulfilled' and a lookup field,
Contact__c, to Contact.
Which SOQL query will return a unique list of all the Contact records that have no `˜Fulfilled' Orders?
Answer options
- A. SELECT Id FROM Contact WHERE Id NOT IN (SELECT Id FROM Order__c WHERE Status__c = 'Fulfilled')
- B. SELECT Contact__c FROM Order__c WHERE Status__c <> 'Fulfilled'
- C. SELECT Id FROM Contact WHERE Id NOT IN (SELECT Contact__c FROM Order__c WHERE Status__c = 'Fulfilled')
- D. SELECT Contact__c FROM Order__c WHERE Id NOT IN (SELECT Id FROM Order__c Where Status__c = 'Fulfilled')
Correct answer: D
Explanation
The correct answer is D because it attempts to select Contacts that do not have any associated Orders with the status 'Fulfilled'. Option A is incorrect as it checks the Ids of Contacts instead of ensuring they have no Fulfilled Orders. Option B returns Orders instead of Contacts, and Option C incorrectly checks for Contact__c instead of focusing on the Order records.