SanAntonioSpurFan
Instructor
I have 4 tables (Products,Dates,Stores,Sales). The products table contains the primary key UPC along with other fields. The Dates table contains primary Key WeekID along with other fields. The Stores table contains StoreID primary Key along with other fields. And the Sales table contains UPC, WeekID, StoreID, Dollars. Each primary key is related back to each individual table. The relationships look ok to me.
In the Dates table I have WeekID layed out until 2015 by incrementing numbers in the WeekID field. As each weeks data becomes available, I change the value of the DateSwitch Field from "N" to "Y" thus signaling this weeks data is now available.
I want to create a query that will do the following: Look up the highest value for WeekID in Date table where DateSwitch is equal to "Y". Otherwise I think it will pick a number that is equal to "N" and I don't care about those weeks since they have not occured. Once I know that value, say it's 2500 then I want it to prompt me for the number of weeks to sum up together. If I enter 12, It should use the between or something like between 2500 and 2488 to give me the sum of 12 weeks. I also want it to get the sales from last years 12 week period also on the same record.
So it would look like this:
UPC, StoreID, Current Sales, Last Year Sales
I'm not sure how to tell it to get all last year sales and all this year sales so my numbers all add up.
Each week I get data in the following layout
StoreID,WeekID,UPC,Dollars
I need the values on the same line to compute %Change vs LY on all items and other calculations.
Does anyone have any advise/directions I should take and how to best construct this query?
In the Dates table I have WeekID layed out until 2015 by incrementing numbers in the WeekID field. As each weeks data becomes available, I change the value of the DateSwitch Field from "N" to "Y" thus signaling this weeks data is now available.
I want to create a query that will do the following: Look up the highest value for WeekID in Date table where DateSwitch is equal to "Y". Otherwise I think it will pick a number that is equal to "N" and I don't care about those weeks since they have not occured. Once I know that value, say it's 2500 then I want it to prompt me for the number of weeks to sum up together. If I enter 12, It should use the between or something like between 2500 and 2488 to give me the sum of 12 weeks. I also want it to get the sales from last years 12 week period also on the same record.
So it would look like this:
UPC, StoreID, Current Sales, Last Year Sales
I'm not sure how to tell it to get all last year sales and all this year sales so my numbers all add up.
Each week I get data in the following layout
StoreID,WeekID,UPC,Dollars
I need the values on the same line to compute %Change vs LY on all items and other calculations.
Does anyone have any advise/directions I should take and how to best construct this query?