Why is this SOQL query not working?
I'm trying to retrieve duplicate accounts, by I need the Id for each specific account that's why I didn't just use the subselect query which would give me a grouped result.
SELECT Id, ebMobile__ERPAccountNumber__c
FROM Account
WHERE Id IN (
SELECT Id
FROM Account
WHERE ebMobile__ERPAccountNumber__c != null
GROUP BY ebMobile__ERPAccountNumber__c
HAVING COUNT(Id) > 1
)
Salesforce Inspector returns this error:
MALFORMED_QUERY:
GROUP BY ebMobile__ERPAccountNumber__c
^
ERROR at Row:7:Column:4
expecting a right parentheses, found 'GROUP'
Dev Console just says: Unknown error parsing query