SELECT AccountId, Account.name
FROM Opportunity
WHERE StageName LIKE '%Closed%'
I seek a query that works the same but should be called "From Account". Also that returns records that have null as their name or AccountId.
SELECT AccountId, Account.name
FROM Opportunity
WHERE StageName LIKE '%Closed%'
I seek a query that works the same but should be called "From Account". Also that returns records that have null as their name or AccountId.
SELECT Id, Name
FROM Account
WHERE Id IN (
SELECT AccountId
FROM Opportunity
WHERE StageName IN ('Closed Won', 'Closed Lost')
)
It's almost verbatim in the documentation, you could have searched bit more.
(...)the following query returns account IDs if an associated opportunity is lost
SELECT Id, Name
FROM Account
WHERE Id IN
( SELECT AccountId
FROM Opportunity
WHERE StageName = 'Closed Lost'
)