我有一个具有以下模式的Mail模型:
t.string "mail"
t.integer "country"
t.boolean "validated"
t.datetime "created_at"
t.datetime "updated_at"我想在数据库中找到前5个国家/地区,所以我继续输入
@top5 = Mail.find(:all,:group => 'country',:conditions => [ "validated = ?" , "t" ], :limit => 5 )这将告诉我组(我需要一个我不知道怎么写的命令)
@top5 = Mail.count(:all,:group => 'country',:conditions => [ "validated = ?" , "t" ], :limit => 5 )这将告诉我每组中有多少封邮件
我想知道我是否可以在一次操作中分组和计数
https://stackoverflow.com/questions/499767
复制相似问题