Skip to content

Instantly share code, notes, and snippets.

@ernest-ns
Created March 3, 2016 12:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ernest-ns/7fd3c2db849920409e7c to your computer and use it in GitHub Desktop.
Save ernest-ns/7fd3c2db849920409e7c to your computer and use it in GitHub Desktop.
Rails Script to find Duplicate entries in the DB
User.select(:first,:email).group(:first,:email).having("count(*) > 1").count
#{[nil, nil]=>512,
# ["Joe", "test@test.com"]=>23,
# ["Jim", "email2@gmail.com"]=>36,
# ["John", "email3@gmail.com"]=>21}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment