【发布时间】:2015-01-21 19:22:59
【问题描述】:
我想按唯一属性对 attribute1 attribute2 计算记录。
所以对于表foo
-----------------------------
id | attribute1 | attribute2 |
-----------------------------
1 | x | y |
2 | x | y |
3 | x | y1 |
4 | x1 | y1 |
我想得到 count = 3,所以计算记录:([x,y], [x,y1], [x1,y1])。
如何用 ActiveRecord 编写这个查询?
【问题讨论】:
标签: mysql sql ruby-on-rails ruby