Translating @TuteC into ActiveRecord:
sql="SELECT id,
COUNT(id) as quantity
FROM types
GROUP BY name
HAVING quantity > 1"
#=>
Type.select("id, count(id) as quantity")
.group(:name)
.having("quantity > 1")
Translating @TuteC into ActiveRecord:
sql="SELECT id,
COUNT(id) as quantity
FROM types
GROUP BY name
HAVING quantity > 1"
#=>
Type.select("id, count(id) as quantity")
.group(:name)
.having("quantity > 1")