Created
November 2, 2015 15:08
-
-
Save npassaro/795dbb4a387a7e6a028b to your computer and use it in GitHub Desktop.
Find how many duplicate strings (independently of case) exist in a table
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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