MySQL Forums
Forum List  »  Newbie

Average of columns Help Needed
Posted by: Bruce Smith
Date: January 23, 2017 06:09AM

I have a table that records the forecasted orders in a month
Each month for each product a new row is created.

ForecastID SalesSKU MonthNo Date Quantity
1 ABC101 1 01/01/2017 300
2 ABC101 2 01/02/2017 750
3 ABC101 3 01/03/2017 800
4 ABC101 4 01/04/2017 550
5 ABC101 5 01/05/2017 600
6 ABC101 6 01/06/2017 450
7 ABC101 7 01/07/2017 280
8 ABC101 8 01/08/2017 370
9 ABC101 9 01/09/2017 120
10 ABC101 10 01/10/2017 550
11 ABC101 11 01/11/2017 600
12 ABC101 12 01/12/2017 800
13 ABC101 13 01/01/2018 500


I want to add a column to the above table that averages out the current month, the previous 2 months and the next 2 months. I appreciate that the formula would be different for monthNo 1 and 2 but does anyone have a formula that would work for all months afer month 1 and 2?
Happy also with a view that does the same. I just need to display the averages and be able to relate that back to a salesSKU, a month and a year.
Any help would be appreciated

Options: ReplyQuote


Subject
Written By
Posted
Average of columns Help Needed
January 23, 2017 06:09AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.