I am looking for a MS SQL stored procedure that will calculate average monthly sales and a Exponential Moving Average (EMA) for sales of different products.
You will first need to look at the prior sales and look for irregular sales for any specific product. For example, we might normally sell one unit at a time for a given product, but there is one irregular sale that has 80 units. Any irregular sales need to be removed from the dataset before the calculations below are started.
First, I need a simple 30 day average of the last 180 days computed. Simply find the total units of each product sold for the last 180 days (from the date the SP is run) and divide by six. You will update a field for each product with the result.
Then, I want to be able to get and record the current value of the Exponential Moving Average (EMA) based on the number of days and time period specified. I would like to be able to specify a start date, end date, and the number of days for the EMA. For example, I may want the 10 day EMA for the period of January 1, 2007 to June 30, 2007. Or, I may want a 30 day EMA for the period of December 1, 2005 to August 7, 2007.
If needed, you can get the formulas for the EMA from various sites. Check out <[login to view URL]>.
The value of the EMA will be recorded for each product.
Here are what the tables you will be dealing with look like:
[login to view URL] (primary)
[login to view URL] (you will record the simple average here)
[login to view URL] (you will record the EMA here)
[login to view URL] (primary)
[login to view URL]
[login to view URL]
[login to view URL] (where Cancelled = 0)
[login to view URL]
This will be running on a MS SQL 2000 server.
## Deliverables
1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.
2) Deliverables must be in ready-to-run condition, as follows (depending on the nature of the deliverables):
a) For web sites or other server-side deliverables intended to only ever exist in one place in the Buyer's environment--Deliverables must be installed by the Seller in ready-to-run condition in the Buyer's environment.
b) For all others including desktop software or software the buyer intends to distribute: A software installation package that will install the software in ready-to-run condition on the platform(s) specified in this bid request.
3) All deliverables will be considered "work made for hire" under U.S. Copyright law. Buyer will receive exclusive and complete copyrights to all work purchased. (No GPL, GNU, 3rd party components, etc. unless all copyright ramifications are explained AND AGREED TO by the buyer on the site per the coder's Seller Legal Agreement).
## Platform
MS SQL 2000