title: Rails way of sum query with join and calculation
body: <p>I have the following query</p>
  
  <pre><code>@entity = Unit.joins(:item).select('SUM((items.entity/items.amount*units.amount)) AS entity')
  </code></pre>
  
  <p>How can this be done in a more rails like way?</p>