Question: I NEED HELP THOSE SQL CODE ARE NOT WORKING 1. Create a query that returns the unique combinations of customers (companyname) have bought what products

I NEED HELP THOSE SQL CODE ARE NOT WORKING

1. Create a query that returns the unique combinations of customers (companyname) have bought what products (productname) that is I dont want duplicate customer-product combinations.

SELECT DISTINCT c.CompanyName, p.ProductName

FROM Customers c

JOIN Orders o ON c.CustomerID = o.CustomerID

JOIN OrderDetails od ON o.OrderID = od.OrderID

JOIN Products p ON od.ProductID = p.ProductID;

OR

SELECT DISTINCT c.CompanyName, p.ProductName FROM Customers c JOIN Orders o ON c.CustomerID = o.CustomerID JOIN OrderDetails od ON o.OrderID = od.OrderID JOIN Products p ON od.ProductID = p.ProductID;

2. Create a query that shows the 10 most expensive orders (unitprice * quantity is sufficient for the calculation), make sure to output both the OrderID and the total order price.

SELECT TOP 10 OrderID, (UnitPrice * Quantity) AS TotalOrderPrice FROM OrderDetails ORDER BY TotalOrderPrice DESC;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!