For the questions below, use the W3Schools customer orders database. You need to
ID: 3799037 • Letter: F
Question
For the questions below, use the W3Schools customer orders database. You need to submit thoroughly tested SQL statements. For your convenience and reference, relevant data model is attached as a PDF document with the assignment in the Blackboard. Name of this document is "Relationship diagram for W3schools order pdf." 1) Write a query to show Customers' Country wise sales totals. Your query should show Customers' Country name and the total sale value for that Country 2) Write a query to show Product wise sales totals. Your query should Product name and the total sale value for that Product. 3) Write a query to show the number of orders for each shipper. Your query should show shipper name and the count of orders with the shipper. 4) Write a query to show number of products in each product category. Your query should show Category name and number of products in that category 5) Write a query that shows Customers' country wise customer count, and order count. Your query should show country name, total number of customers from that country, and total number of orders from the customers of that country 6) Write a query that shows the number of products supplied by each Supplier. Your query should show Country name, supplier name and the count of products supplied by that supplier. Note: Sale Price Orderdetails.Quantity Products.price (see an example in the class slides deck) W3SCHOOLS SQL is located at http://www.w3schools.com/sql/default.asp (Preferred browser is Chrome). On this page you will find a button called "Try it yourself". Click on that button. You will be redirected to a page where you see a list of tables on the right side of the page. It is highly recommended to click 'Restore Database' button on this page during every session. The page contains a box where you can type in an SQL statement involving the listed tables. You type in your SQL statement in that box and click on "Run SQL'' button. The results will be displayed if your SQL statement is syntactically correct.Explanation / Answer
1. SELECT Customers.Country, SUM(OrderDetails.Quantity * Products.Price) AS Total_Sale FROM Customers
LEFT JOIN Orders ON Customers.CustomerID=Orders.CustomerID
LEFT JOIN OrderDetails ON Orders.OrderId=OrderDetails.OrderId
LEFT JOIN Products ON OrderDetails.ProductId=Products.ProductId
Group BY Customers.Country;
2. SELECT Products.ProductName, SUM(OrderDetails.Quantity * Products.Price) AS Total_Sale FROM Customers
LEFT JOIN Orders ON Customers.CustomerID=Orders.CustomerID
LEFT JOIN OrderDetails ON Orders.OrderId=OrderDetails.OrderId
LEFT JOIN Products ON OrderDetails.ProductId=Products.ProductId
Group BY Products.ProductName;
You can edit these query to get other results set.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.