Take the 2-minute tour ×

I'm changing a field to be unique, but currently some accounts have the same value in that field.

How can I get a count of how many fields currently have non-unique values in that field?


share|improve this question
add comment

1 Answer

You can run a SOQL aggregate query to find the values that aren't unique, e.g.

select name from account group by name having count(name) > 1

[Edit] You can also count each value, e.g. this will show you how many rows have each non unique value.

select name, count(id) num from account group by name having count(name) > 1
share|improve this answer
add comment

Your Answer


