Hoge.group(:foo).sum(:bar)
# { foo => (barの合計) } という形のhashが返る
Hoge.group(:foo).select("foo, sum(bar)")
# Hogeクラスが返る
上だとHashなのでlimitやorderが使えないが下だとlimitやorderが使える
Go to list of users who liked
Share on X(Twitter)
Share on Facebook
More than 5 years have passed since last update.
Hoge.group(:foo).sum(:bar)
# { foo => (barの合計) } という形のhashが返る
Hoge.group(:foo).select("foo, sum(bar)")
# Hogeクラスが返る
上だとHashなのでlimitやorderが使えないが下だとlimitやorderが使える
Register as a new user and use Qiita more conveniently
Go to list of users who liked