I think I have confused myself on trying to come up with the following SQL logic. Can anyone steer me in right direction?
I need to create a loop that would start on current day, and and look back 52 weeks. But but each week and insert into a table.
for example lets say this ran on this coming friday 05/10. I would need the code look back at last weeks 05/03 and return all records that have a invoice with this date and insert into a table with a column labeling the these records as week17.
Then once it has found all week17 records, I would need it to loop back through to the next week which would be week16. and then repeat this for 52weeks