Database Homework Must Use SQL On https://www.w3schools.com/sql/trysql.asp?filen
ID: 3799949 • Letter: D
Question
Database Homework
Must Use SQL On https://www.w3schools.com/sql/trysql.asp?filename=trysql_select_all
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. Write a query to show Product wise sales totals. Your query should Product name and the total sale value for that Product. 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. 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. 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. 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.Explanation / Answer
hi ,
please find the quesries for all the questions listed.
1.
query:
SELECT c.country, sum(quantity*price) sales FROM [OrderDetails] od
inner join products p on od.productid=p.productid
inner join orders o on o.orderid = od.orderid
inner join customers c on c.customerid = o.customerid
group by c.country
2.
SELECT p.Productname, sum(quantity*price) sales FROM [OrderDetails] od
inner join products p on od.productid=p.productid
inner join orders o on o.orderid = od.orderid
group by p.Productname
3.
SELECT count(1) [no.of orders],ShipperName FROM [Orders] o inner join shippers s on s.shipperid = o.shipperid
group by ShipperName
4.
SELECT CategoryName,count(c.categoryid) [no.of products] FROM [Categories] c inner join products p on c.categoryid= p.categoryid
group by CategoryName
5.
SELECT country,count(distinct c.customerid) [No of Customers],count(distinct o.orderid) [No of Orders] FROM [Customers] c inner join orders o on o.customerid = c.customerid
group by country
6.
SELECT country,suppliername,count(productid) [no.of products] FROM [Products] p inner join suppliers s on s.supplierid =p.supplierid
group by country,suppliername
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.