+ Start a Discussion
Shubham SengarShubham Sengar 

SOQL Problem 6

Get all accounts that do not have any open opportunities by soql code??
Best Answer chosen by Shubham Sengar
Neetu_BansalNeetu_Bansal
Hi Shubham,

Select Id, ( Select Id from Opportunities where StageName != 'Open') from Account

If this help, please mark as best answer so will help others also.

Thanks,
Neetu

All Answers

Neetu_BansalNeetu_Bansal
Hi Shubham,

Select Id, ( Select Id from Opportunities where StageName != 'Open') from Account

If this help, please mark as best answer so will help others also.

Thanks,
Neetu
This was selected as the best answer
William TranWilliam Tran

I don't think that will work.

That will retrieve ALL accounts and populate the extra column if the StageName != 'Open'.

But if it works for you, this questions is resolved.

Thx

ssssssssssssss
As William rightly pointed out, the above query does not show the correct results. The correct query would be:
 
Select id, account.id, account.name, stagename from opportunity where IsClosed = FALSE

~S