Could anybody please help me to find the total of the elements in the
records?
I have one products table. In that table, price is the entity. I want to
add the total of all the products.
Created At Product Price
2006-09-18 Ruby 4.5
2006-09-18 Ruby 4.5
2006-09-18 Ruby 4.5
2006-08-04 shq 8.0
I want to get the total as “21.5” as i added all of them. So how to do
that?? Please give me in detail.
Thanks in advance.
Harish
Naga harish Kanegolla wrote:
Could anybody please help me to find the total of the elements in the
records?
I have one products table. In that table, price is the entity. I want to
add the total of all the products.
Product.sum(‘price’) (assuming your model is called product). You can
add the usual :conditions stuff and so on in order to further contrain
things.
Fre
Thanku very much Frederick C… It worked for me.
Frederick C. wrote:
Naga harish Kanegolla wrote:
Could anybody please help me to find the total of the elements in the
records?
I have one products table. In that table, price is the entity. I want to
add the total of all the products.
Product.sum(‘price’) (assuming your model is called product). You can
add the usual :conditions stuff and so on in order to further contrain
things.
Fre