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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Thanku very much Frederick Cheung. It worked for me. Frederick Cheung 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-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---