Skip to content

Instantly share code, notes, and snippets.

@airspeed
Last active December 18, 2015 10:09
Show Gist options
  • Save airspeed/5766143 to your computer and use it in GitHub Desktop.
Save airspeed/5766143 to your computer and use it in GitHub Desktop.
Schweizer bestellte Anzahl mit Datumfilter.
OrderItem.where(:created_at => Date.parse('2013-04-01')..Date.parse('2013-07-31')).select{|b| b.address.country_code == "CH"}.map(&:quantity).sum
# noch flexibler
OrderItem.where(:created_at => Date.parse('2013-04-01')..Date.today).select{|b| b.address.country_code == "CH"}.map(&:quantity).sum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment