例如:
- Person.count("age > 21")
- Person.average(:age)
- Person.minimum(:age)
- Person.maximum(:age)
- Person.average(:age, :conditions => ["name like ?", '%T%'])
- Donation.sum(:amount, :group => :created_at)
- Donation.sum(:amount, :group => 'YEAR(created_at)')
- Rating.average(:value, :group => :post).collect{|post, rating| [post.title, rating]}
- Rating.average(:value, :group => :post)[Post.find(2)]
- Person.find_by_name("Adam").ratings.average(:value)
安徽新华电脑学校专业职业规划师为你提供更多帮助【在线咨询】