title: Select, group and sum results from database
body: <p>I have a database with some fields I'd like to sum. But that's not the big problem, I want to group those fields by the month they were created. ActiveRecord automaticaly created a field named "created_at". So my question; how can I group the result by month, then sum the fields for each month?</p>
  
  <p><strong>Updated with code</strong></p>
  
  <pre><code>@hours = Hour.all(:conditions =&gt; "user_id = "+ @user.id.to_s, 
                    :group =&gt; "strftime('%m', created_at)",
                    :order =&gt; 'created_at DESC')
  </code></pre>
  
  <p>This is the code I have now. Managed to group by month, but doesn't manage to sum two of my fields, "mins" and "salary" which I need to sum</p>