Created
February 23, 2011 20:34
-
-
Save henriquegogo/841130 to your computer and use it in GitHub Desktop.
Exemplo de uma soma da quantidade de determinado registro num período
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
q=0; | |
r = Registro.find(:all, :conditions => ["created_at BETWEEN ? AND ?", Date.new(2010,6,1), Date.new(2010,7,1)]) | |
r.each do |reg| | |
q = (q + reg.quantidade) | |
end | |
puts q |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment