I have two main tables; calendar and transactions. I'm trying to SUM the transactions for each Year, Term, and Week for each store in separate queries. However, I'm also trying to return the previous year's Sum for each Year/Term/Week, but the calendar we use is an accounting calendar that shifts dates YoY.
My question is, how do I return the SUM for the previous Year's period of aggregation in the same line? To put in another way - I am trying to take window periods of dates, and then sum the transactions for each window period, but the window periods are for previous periods of aggregation and then get those to return in the same line.