I am trying to find pricing of products (from BRANDS) between dates that I select and then get the Percent Change using four tables.
For example, if I choose dates 1/1/18 and 3/31/18, it will look for each product, get the most recent price on 1/1/18, then the most recent price on 3/31/18 and calculate % Change, if any.
PROD 1, latest price is on 3/12/14 at $10 (Would be the price for 1/1/18). Has a price change on 2/6/18 and is now $15 (3/31/18 price). Calculates the price change as 50%.
Doesn't matter how many price changes between 1/1/18 and 3/31/18. Just take the price on those 2 dates.
If there is no beginning price, it will not be included in the results
TABLE ONE (DefinedBrands) - a list of BRANDS I defined and uploaded. Each is unique
BRAND Brand1 Brand2 Brand3 Brand4
TABLE TWO (AllBrands) - connected to TABLE ONE to get the BRAND ID
BrandID
BRAND
1 Brand1 2 Brand2 3 Brand3 4 Brand4
TABLE THREE (AllProducts) - contains PRODUCTS for each BRAND. Connected by TABLE TWO ID
ProdID
BrandID
ProductName
1 1 Prod1 2 1 Prod2 3 1 Prod3 4 1 Prod4 5 2 Prod5 6 2 Prod6 7 2 Prod7 8 2 Prod8 9 3 Prod9 10 3 Prod10 11 3 Prod11 12 3 Prod12 13 4 Prod13 14 4 Prod14 15 4 Prod15
TABLE 4 (ProdPricing) - Contains price and dates for products.
ProdID
DATE
PRICE
1 3/12/14 10.00 1 2/6/18 15.00 2 1/1/18 2.00 2 2/6/18 1.85 2 3/12/18 4.00 3 2/8/17 5.00 3 1/2/18 8.00 3 1/9/18 12.00 4 9/6/15 7.00
Please let me know if there is any other info needed. Thank you in advance.