Aggregate function and group by
Account.find :all, :select => "COUNT(last_name) AS total, *", :group => "last_name"
which would result in the following SQL:
SELECT COUNT(last_name) AS total, * FROM accounts GROUP BY last_name
Related examples in the same category