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 how many vendors supplied products that are priced lower than 185?

2- For each vendor, find their product that has the lowest product quantity. Your output should include vendor code, vendor name, product name and product quantity for each vendor.

3- Find how many products are there in each invoice. The output should include invoice number and number of products in the invoice.

4- Find how many invoices are made by each customer. The output should be a list of cus_code and for each cus_code, the number of invoices made by this customer.

5- 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.

6- Find vendor code, vendor contact and the number of products supplied by each vendor.

7- Find product description, price, and vendor code for the cheapest (lowest price) product.

8- 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.

9- 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.

10- 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

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!