Question Locked

SQL Query - Grouping Sales In Rolling 10 Day Increments

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I've been asked to go thru our last 6 months of sales, by day, and get a rolling average by 10 day increment to graph trends. We only one table with product name and date sold in it. Any ideas? It's probably simple to most, butI've never grouped like this before.

Thanks in advance.

3 replies

by jonomck

Easy in Excel, but possible in SQL, something like the code below shoud do what you want. Ugly but it works

select
date,
(select sum(sales) from Sales_table as t1
where DATEDIFF(day,t1.date,t.date) between 0 and 9
and " any other join details)/10 as aver sales
from Sales_table as t

by cliff_hand

JonoMck,

Thank you for the effort. I will try to carve something up in SQL with what you have above. I was concerned because I had not rec'd any posts on the question. On the flip side, I was relieved that, apparently, no 'experts' knew how to do it either. Or, if they do, they just haven't taken the time to respond.

If anybody else happens to read this, I'm open to any other suggestions, too.

Thanks

This discussion is closed to new replies.