You need to sign in to do that
Don't have an account?
GROUP and LIMIT in conflict with using variables in query?
I am using this query in an APEX class
var domainNameLike = '%mydomain.com';
accounts = [SELECT Id, Name FROM Account WHERE Id IN (SELECT AccountId FROM Contact WHERE Email LIKE :domainNameLike)];
For performance reason I want to limit the number of results with a GROUP BY and/or LIMIT statement in the WHERE subquery like this:
accounts = [SELECT Id, Name FROM Account WHERE Id IN (SELECT AccountId FROM Contact WHERE Email LIKE :domainNameLike GROUP BY AccountId LIMIT 10)];
However when I am trying to save this, it throws an exception "Error: Compile Error: expecting a right parentheses, found 'GROUP' "
does the variable :domainNameLike somehow conflict with GROUP or LIMIT statements?
What am I doing wrong? How can I limit and group in that subquery?
Thanks
Alex
I'm not sure you can do that in the nested subquery...
If you're already querying all the contact rows, you can use a sObject set to give you a unique list, which is probably just as easy...