nathan-castor
4/17/2018 - 9:26 PM

month_over_month

-- select to_char(current_date, 'day') THE WORD TUESDAY :)
-- select extract(dow from  current_date) THE NUMBER 2 :)

-- TIME INTERVAL: current_date - interval '7 day'

extract(dow from  date_trunc('week',event_date))

select month, sum(cnt) over (order by month asc) as running_total from
        (
            select count(*) as cnt,
            date_trunc('month',event_date) as month
            from reports_account_status_history
            where 1=1            
	 group by 2
        ) monthly_totals