Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Average over the past 4 days of the week

$
0
0

Hi

How can I take the day of the week and average it for the past 4 days of the week e.g. the average for the past 4 Mondays

CREATE

TABLE dbo.average(



first_date

datetime,

first_date_day

nvarchar(50),

figure

nvarchar(50)

);



INSERT

INTO dbo.averageVALUES('2013-05-06','Saturday','25');


INSERT

INTO dbo.averageVALUES('2013-05-05','Sunday','34');


INSERT

INTO dbo.averageVALUES('2013-05-06','Monday','54');


INSERT

INTO dbo.averageVALUES('2013-05-07','Tuesday','75');


INSERT

INTO dbo.averageVALUES('2013-05-08','Wednesday','34');


INSERT

INTO dbo.averageVALUES('2013-05-09','Thursday','65');


INSERT

INTO dbo.averageVALUES('2013-05-10','Friday','33');


INSERT

INTO dbo.averageVALUES('2013-05-11','Saturday','45');


INSERT

INTO dbo.averageVALUES('2013-05-12','Sunday','23');


INSERT

INTO dbo.averageVALUES('2013-05-13','Monday','54');


INSERT

INTO dbo.averageVALUES('2013-05-14','Tuesday','87');


INSERT

INTO dbo.averageVALUES('2013-05-15','Wednesday','65');


INSERT

INTO dbo.averageVALUES('2013-05-16','Thursday','12');


INSERT

INTO dbo.averageVALUES('2013-05-17','Friday','43');


INSERT

INTO dbo.averageVALUES('2013-05-18','Saturday','65');


INSERT

INTO dbo.averageVALUES('2013-05-19','Sunday','24');


INSERT

INTO dbo.averageVALUES('2013-05-20','Monday','14');


INSERT

INTO dbo.averageVALUES('2013-05-21','Tuesday','64');


INSERT

INTO dbo.averageVALUES('2013-05-22','Wednesday','34');


INSERT

INTO dbo.averageVALUES('2013-05-23','Thursday','23');


INSERT

INTO dbo.averageVALUES('2013-05-24','Friday','18');


INSERT

INTO dbo.averageVALUES('2013-05-25','Saturday','56');


INSERT

INTO dbo.averageVALUES('2013-05-26','Sunday','45');


INSERT

INTO dbo.averageVALUES('2013-05-27','Monday','34');


INSERT

INTO dbo.averageVALUES('2013-05-28','Tuesday','65');


INSERT

INTO dbo.averageVALUES('2013-05-29','Wednesday','45');


INSERT

INTO dbo.averageVALUES('2013-05-30','Thursday','67');


INSERT

INTO dbo.averageVALUES('2013-05-31','Friday','65');


Viewing all articles
Browse latest Browse all 23857

Trending Articles



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