0

例如,我有 4 条账单记录。

id    = 1 
prize = 100
city  = "newyork"

id    = 2
prize = 200
city  = "NEWYORK"

id    = 3 
prize = 300
city  = "Boston"

id    = 4
prize = 400
city  = "BOSTON"

我想获得带有哈希值的城市的统计数据{"Newyork" => 2 , "Boston" => 2 }

4

1 回答 1

0
your_collection.group_by(&:city)
于 2013-03-03T14:44:17.590 回答