You need to sign in to do that
Don't have an account?
Mike Summitt
SOQL Syntax in developer console
I've created a SOQL statement designed to locate accounts for which the primary contact cannot be determined, that is, accounts where there is more than one contact, but the accountcontactroles do not specify any primary. The SOQL won't parse, says "Unknown parsing error". Can anyone see what's wrong with it?
SELECT Id
FROM Account
WHERE Id IN (SELECT Account FROM Contact GROUP BY Account HAVING Count(Id) > 0)
AND Id NOT IN (SELECT AccountID Id FROM AccountContactRole WHERE IsDeleted = false and IsPrimary = true)
SELECT Id
FROM Account
WHERE Id IN (SELECT Account FROM Contact GROUP BY Account HAVING Count(Id) > 0)
AND Id NOT IN (SELECT AccountID Id FROM AccountContactRole WHERE IsDeleted = false and IsPrimary = true)
pcon
From what I can see, you get that error when you use having in a subquery. I don't know if it's a limitation or a bug. I would file an issue with Salesforce to see which it is.