select count(distinct user_id)的な
最近Railsをちょいちょいさわる機会があります。
よくある、
select count(distinct user_id) from hoge_users;
みたいなSQLですが、ActiveRecordだと
Hoge_users.count('user_id', :distinct => true)
でいける。簡単でいいですね。
最近Railsをちょいちょいさわる機会があります。
よくある、
select count(distinct user_id) from hoge_users;
みたいなSQLですが、ActiveRecordだと
Hoge_users.count('user_id', :distinct => true)
でいける。簡単でいいですね。