I need to make the sum of a specific column, grouped by date and month. In SQL (postgres), it will look something like this:
select sum(amount) from somewhere group by extract(year from date), extract(month from date)
Can this be expressed as Django QuerySet? I don't seem to like this, but I really don't want to resort to plain old SQL. Any other ideas are welcome.
It seems like it's possible using queryset.query.group_by, but I was out of luck - a working example would be welcome.
source
share