Mega Code Archive

 
Categories / Ruby / Active Record
 

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