I am trying to automate a report that runs at the beginning of each month to query out all sales for the previous month. Given below is the query I am using but it returns null value. Could anyone help me with what I am doing wrong here.
I am using Amazon Redshift
select created_at,sale_id from billing where to_char(created_at,'yyyy-mm') = EXTRACT(month FROM CURRENT_DATE - '1 month'::interval); Thanks.