Skip to content

Instantly share code, notes, and snippets.

@npassaro
Created November 2, 2015 15:08
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 npassaro/795dbb4a387a7e6a028b to your computer and use it in GitHub Desktop.
Save npassaro/795dbb4a387a7e6a028b to your computer and use it in GitHub Desktop.
Find how many duplicate strings (independently of case) exist in a table
-- Arel
select("COUNT(*)").select("LOWER(name) AS name").group("LOWER(name)").having("COUNT(*) > 1")
-- SQL
SELECT COUNT(*), LOWER(name) AS name FROM "occupations" GROUP BY LOWER(name) HAVING COUNT(*) > 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment