Quantcast
Channel: Forum Getting started with SQL Server
Viewing all articles
Browse latest Browse all 7129

NEED HELP WITH 12 WEEKS ROLLING DATA

$
0
0

Hi All

Need help in finding out total sum of  lottery wins in one week along with 12 week rolling data. I am attaching a snapshot of the data. I have found the sum of lottery wins per market split by last day of week, but not sure how to find out rolling 12 week data.

I am attaching excel screenshot

 

I have done the sum of finding lottery wins per week 

SQL Code:- 

select last_day_of_week,MARKET
,sum(real_gw)
from data_imp
where LAST_DAY_OF_WEEK between dateadd(day,-77,last_day_of_week) and LAST_DAY_OF_WEEK
group by LAST_DAY_OF_WEEK,market

I am not sure how do i find out rolling 12 weeks based on this date range. If you see the excel screenshot the way to find rolling 12 week is explained in the formula bar. 

My end result should be a display of last_day_of_week,market,total,total of rolling 12 week data all in one sql query as you see in the excel screenshot

Would appreciate all helps given

Regards

Farhan Jamil



Viewing all articles
Browse latest Browse all 7129

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>