First of all, there are not enough information to help you. But if I understand, you have this schema (Assume that we have model called Entity):
date:date
sold:integer
So, if if you have such table, the query to calculate all entities should be like this:
@entities = Entity.all
@entities.sum(&:sold) * price #=> Price multiplied by total sum of sold.
If you need to sum only specified range, you can handle it like here: Rails - Filter by date range