05-20-2016 10:48 PM
I am trying to lookup the value in another column of the table based on the value in different column of the same table. For an example, if I have a three column table : one column is the product ID, another - the number of products sold, and last - total sales in $. I am trying to write a code to locate the quantity of the product and its ID that was in most demand (for sales) and what was the corresponding sales for this product in $?
Hope this is not too confusing.
05-21-2016 02:23 PM
05-21-2016 06:26 PM - edited 05-21-2016 07:20 PM
I have two tables:
One has the actual sales data:
Date Product_ID Quantity Sold $ Sales
9/20/2014 11 78 390
9/21/2014 157 100 200
9/22/2014 287 500 5000
9/23/2014 14 280 4200
9/24/2014 11 10 50
9/25/2014 287 161 1610
The other- a table with the numbers of products we need to do a query on:
As can be seen from the query table above, not all products IDs have been actually sold over given time period. The output needs to give detail only on the items that actually sold, and look something like the below or other suitable format:
Thank you for your help
05-22-2016 02:36 AM
Need further help from the community? Please ask a new question.