1

I want to find the AccountId that is most of times used as Duplicate Record Item. I tried

select id, count(RecordId)
from DuplicateRecordItem
group by RecordId

but i get

MALFORMED_QUERY: 
select id, count(RecordId)
                 ^
ERROR at Row:1:Column:18
Grouped field should not be aggregated: RecordId

What is the correct query ?

1

The following query should make the trick:

SELECT COUNT(Id), RecordId
FROM DuplicateRecordItem
GROUP BY RecordId
ORDER BY COUNT(Id) DESC
LIMIT 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.