4 ms·
In PostgreSQL you would group by date_trunc('month', transaction_date)
by ants_a 5y ago
In PostgreSQL you would group by date_trunc('month', transaction_date)
- function_seven 5y agoThat would produce dates instead of integers though. I want a table that looks like this: MonthsAgo | Sales ================== 4 | 4,500 3 | 7,204 2 | 12,578 1 | 15,748 0 | 34,485 And maybe use a parameter so the user can go by week, or quarter, or whatever.