If I am reading this right, yes, you should just be able to do:
@sales_orders = SalesOrder.find(:all, :conditions => ['month(ship_date) = ? and year(ship_date) = ?',@month,@year])
@total = @sales_orders.sum(&:amount)
- Tyler
If I am reading this right, yes, you should just be able to do:
@sales_orders = SalesOrder.find(:all, :conditions => ['month(ship_date) = ? and year(ship_date) = ?',@month,@year])
@total = @sales_orders.sum(&:amount)
- Tyler
Hi ... I think it can be done in one step with:
SalesOrder.sum('amount', :conditions => ['month(ship_date) = ? and
year(ship_date) = ?',@month,@year])
nice if you can let SQL do the math(s)