I have two tables tblProducts (ProductID, ProductName) and tblProductPricing (ProductID,ValidDate, PriceUSD,PriceInd). For each product in tblProducts there may exist 0 to many entries in tblProductPricing Where PriceInd=1 indicates Purchase Cost and PriceInd=2 indicates Sales Prices.
I am trying to find a single SQL to retrieve all products including their respective LATEST cost and sales price (if available). The latest or Valid price is defined by Max(ValidDate) <= Today for each ProductID and PriceInd respectively. Cost and sales price will most likely have different dates.
Thank you so much for your help. Best regards Michael
Gain unlimited access to on-demand training courses with an Experts Exchange subscription.Get Access
Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE
Connect with Certified Experts to gain insight and support on specific technology challenges including: