function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
suji srinivasansuji srinivasan 

Hi , i need to query accounts rating related to opportunities stagename= inprogress,delivered,closedwon

select Id,Rating,(select Id,StageName from Opportunities where StageName=\'WorkInprogress,Delivered,closedwon\') From account

This is my query. its querying all accounts. i need only accounts related to Opportunities where StageName=\'WorkInprogress,Delivered,closedwon\')

Thanks in advance
Best Answer chosen by suji srinivasan
AnkaiahAnkaiah (Salesforce Developers) 
Hi Suji, 

try with below query.
 
select id, stageName,AccountId, Account.Rating from opportunity where stageName IN ('Closed Won','Delivered','WorkInprogress') AND AccountId !=Null

If this helps, please mark it as best answer.

thanks!!