0
ない私は私のコントローラで、私はそうのようにそれを行っている、それらのレコードをレコードをフィルタリングして、合計し、グループする必要があります。合計とグループ・クエリグループ
def view
@templates = Template.where("user_id = #{current_user.id} OR user_id = 1").where("category = 5")
@user_docs = Doc.where("user_id = #{current_user.id}")
@transactions = Transaction.where("doc_id in (?)", @user_docs.map(&:id)).where("template_id in (?)", @templates.map(&:id))
@month = @transactions.select("DATE_TRUNC('month', date) AS month, SUM(amount) AS total_amount_per_month").group('month')
end
それは月のグループ化でエラーを与え、その金額は、私の見解で合計されたすべての月の合計です。なぜ、上記がうまくいかないのでしょうか?私は間違って何をしていますか?