I want to perfom the sql query, SELECT employee_id, sum(period) FROM activity_charts group by employee_id
So far, I was able to do SELECT employee_id, period FROM activity_charts group by employee_id My report_controller.rb is class ReportController < ApplicationController def index @activities = ActivityChart.find(:all, :select => 'employee_id,period', :group => "employee_id")
end end
and the index.html.erb is <h1>Total Hours Worked</h1> <table> <tr> <th width ="180px">Employee</th> <th width ="60px">Minutes</th> </tr> <% @activities.each do |c| %> <tr> <td><%=h c.employee.first_name %> <%=h c.employee.last_name %></td><td><%=h c.period %></td> </tr> <% end %> </table>
How to include sum(period)?