1
votes

I am attempting to write a query on an object, Opportunity, this object has a child object Quotes.

In Quotes where have a field named, Order_Ready.

What I need to do is filter in all opportunities that have approved quotes (Order_Ready__c == true).

Here is the query I have been attempting to get working,

SELECT Id, Name (SELECT Order_Ready__c FROM Quotes) FROM Opportunity WHERE Opportunity.Quotes.Order_Ready__c = true

I have tried a few variations of this,

SELECT Id, Name (SELECT Order_Ready__c FROM Quotes) FROM Opportunity WHERE Quotes.Order_Ready__c = true

SELECT Id, Name (SELECT Order_Ready__c FROM Quotes) FROM Opportunity WHERE Order_Ready__c = true

I have to admit, I'm not the strongest with SQL/SOQL. Any insight into where my mistake or misunderstanding might be?

Thanks!

1
Are you using the standard Quote object? - Jeremy Ross
Standard Opportunity object with a child Quotes - Bryan Harrington
Ok, I updated my answer. - Jeremy Ross

1 Answers

4
votes
SELECT Id, Name FROM Opportunity WHERE Id IN 
(Select OpportunityId FROM Quote WHERE Order_Ready__c = true)