I have a table as simple as two columns Name, Date -- It is a table that has "Leads" in it when user inquiries from our website.
I need to produce a data set of lead count of last 10 rolling weeks?
The expected output is suppose to be
Starting Week -- Count
==============
10 SUM(Last 10 weeks)
9 SUM(Starting from Week 9 for Last 10 weeks)
8 SUM(Starting from Week 8 for Last 10 weeks)
and so on.. it will have 10 rows
its like sliding a week back and sum the last 10 weeks from there
any help?
You can use the following query:
weekSlideis a counter of the week window, i.e. it is0for the week window containing the last 10 weeks starting from current date's week,1for the week window starting from previous week, etc.weekDiffis a computed column containing the offset of [Date] for eachweekSlide. A negative offset implies a [Date] that lies past the week window.Demo here