【发布时间】:2014-10-30 06:40:44
【问题描述】:
我想将 sql 查询转换为 rails 查询
SQL:
select count(*),created_atfrom subscriptions whereaccount_id= (select id fromaccountswheregoogle_domainIS NOT NULL) GROUP BYcreated_atORDER BYcreated_atDESC;
我试过了,但没有得到确切的结果。
我的部分解决方案::
Subscription.joins(:account).where('accounts.google_domain is not null').count
这里我不知道如何使用 group 和 order by。
如果需要任何信息,请发表评论。提前致谢
【问题讨论】:
标签: mysql join ruby-on-rails-4 associations rails-activerecord