I am trying to Calculate MTD sales on daily sales number but my month starts from 26th of previous month to 25th of next month.
data contains only 3 columns (date, vendor_id, total_sales). Below Code is working fine for calculating months starting from the 1st. I tried to do this by using the below approaches but it does not works
- date(date - interval '25 day') : Not working
- Mapping table creation for each day, but will not work for 30/31 days month
Need suggestion on above.
SUM(sales) OVER (
PARTITION BY
vendor_id,
EXTRACT(YEAR FROM date),
EXTRACT(MONTH FROM date)
ORDER BY
date ROWS UNBOUNDED PRECEDING
) AS mtd_total_sales,
