Question: Write SQL statements to answer the following questions using schema (Customer-Invoice-Line-Product-Vendor). customer: 10010, Ramas, Alfred, A, 615, 8442573 10011, Dunne, Leona, K, 713, 8941238 10012,
Write SQL statements to answer the following questions using schema (Customer-Invoice-Line-Product-Vendor).
customer:
10010, Ramas, Alfred, A, 615, 8442573
10011, Dunne, Leona, K, 713, 8941238
10012, Smith, Kathy, W, 615, 8942285
10013, Olowski, Paul,F, 615, 2221672
10014, Orlando, Myron, NULL, 615, 2971228
invoice:
1001, 10011, 2008-08-03
1002, 10014, 2008-08-04
1003, 10012, 2008-03-20
1004, 10014, 2008-09-23
line:
1001, 12321, 1
1001, 65781, 3
1002, 34256, 6
1003, 12321, 5
1002, 12321, 6
product:
12321, hammer, 189 ,20, 232
65781, chain, 12, 45, 235
34256, tape, 35, 60, 235
12333, hanger, 200 ,10, 232
vendor:
232, Bryson, Smith, 615, 2233234
235, SuperLoo, Anderson, 615, 2158995
1- Find the total value for all products in the inventory. The total value in the inventory is the sum of product quantity * product price for all products listed in the product table.
2- Find vendor code, vendor contact and the number of products supplied by each vendor.
3- Find product description, price, and vendor code for the cheapest (lowest price) product.
4- Create a view Alfred that contains customer code, customer last name, and number of invoices made by each customer who has a first name of Alfred.
5- For each invoice, find the total price. The total invoice price is the sum of product price* line units for each product purchased in the invoice.
6- Find how many products are bought by each customer. The output should be a list of cus_code and for each cus_code, the number of products purchased by this customer. A more complex query (if you want to try it), would be to list the name of the customer, along with the cus_code.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
