I\'m using this method:
def self.lines_price_report(n) Income.group(\'date(filled_at)\').having(\"date(filled_at) > ?\", Date.today - n).sum(:lines_
When you want to use Group By on PostgreSQL, The select option should be required on the group by.
Income.select('filled_at').group('date(filled_at)').having("date(filled_at) > ?", Date.today - n).sum(:lines_price)