Question: Write a SQL Code: determine on which purchase order (or purchase orders) Mountain Design paid the highest unit price (price from the PurchaseOrderLine table) for
Write a SQL Code: determine on which purchase order (or purchase orders) Mountain Design paid the highest unit price (price from the PurchaseOrderLine table) for the product Alpine Small Pot. List the PONumber, ProductID, description of the product (from the Product table),the name of the Vendor for the purchase order and Price (from the PurchaseOrderLine table). Be sure to use the description of the product (Alpine Small Pot), rather than the productID, in the WHERE clause(s) to determine the correct row. use a subquery (the subquery from question 1) to make that determination. Sort the result table by PONumber. The result table will have 4 columns: (PONumber, VendorName, ProductID, ProductDescription, and Price)
I came up with the following Code but struggle how to add the vendorName.
SELECT DISTINCT PONumber, tblPurchaseOrderLine.ProductID, ProductDescription, Price FROM tblPurchaseOrderLine INNER JOIN tblProduct ON tblPurchaseOrderLine.ProductID = tblProduct.ProductID WHERE ProductDescription = 'Alpine Small Pot' AND Price = (SELECT MAX(Price) FROM tblPurchaseOrderLine INNER JOIN tblProduct ON tblPurchaseOrderLine.ProductID = tblProduct.ProductID WHERE ProductDescription = 'Alpine Small Pot') ORDER BY PONumber
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
