Skip to content
Advertisement

How to SUM() for past 3 months for every field in a column

I have a table in MS Access that looks something like this

And I want to count for every item in every month, what’s the sum of the past 3/6/12 months and it should look something like this

Is there anyway this can be done in SQL queries?

Advertisement

Answer

Try a self-join on Item and t2.Date <= t1.Date and t2.Date >= dateadd("m",-3,t1.Date).

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement