标签: ruby-on-rails group-by arel
我想将两个不同的列分组并将计数作为嵌套哈希值。
User.group('role').count => gives me {"admin" => 10, "user" => 15}
如何编写查询以获得此类结果(按角色和性别分组)
{"admin" => {"male" => 2, "female" => 3}, "user" => {"male" => 4, "female" => 4}}