Using the table names below I need help finding the questions at the bottom. Con
ID: 3717221 • Letter: U
Question
Using the table names below I need help finding the questions at the bottom.
Consumer Table
Tb_Consumers
Con_ID | Name | City
Offers Table
Tb_Offers
Supp_ID | Prod_ID | Price | Quantity
Product Table
Tb_Products
Prod_ID | Name | MU
Requests Table
Tb_Requests
Con_ID | Prod_ID | Price | Quantity
Supplier Table
Tb_Supplier
Supp_ID | Name | City
Transaction Table
Tb_Transactions
Tran_ID | Supp_ID | Con_ID | Prod_ID | Price | Quantity
QUESTIONS:
--List of supplier names from Wausau and number of offers for each (0 if no offers)
--List of product names and average value of offers for that product (0 if no offers)
--List of product names and number of offers and request for each product (0 if no offers or no request)
--List of product names and average value of offers, request and transactions (0 if no offers or no requests or no transactions).
Explanation / Answer
Following are the queries corresponding to given questions:
1) List of supplier names from Wausau and number of offers for each
SELECT Name,count(Supp_ID)
FROM Tb_Supplier,Tb_Offers
WHERE Tb_supplier.city = 'Wausau' and Tb_Supplier.Supp_ID = Tb_Offers.Supp_ID;
2) List of product names and average value of offers for that product
SELECT Name, avg(Price)
FROM Tb_Products,Tb_Offers
WHERE Tb_Products.Prod_ID = Tb_Offers.Prod_ID;
3) List of product names and number of offers and request for each product
SELECT Name, count(Tb_Offers.Prod_ID), count(Tb_Requests.Prod_ID)
FROM Tb_Products,Tb_Offers,Tb_Requests
WHERE Tb_Products.Prod_ID = Tb_Offers.Prod_ID and Tb_Proucts.Prod_ID = Tb_Requests.Prod_ID ;
4) List of product names and average value of offers, request and transactions
SELECT Name, avg(Tb_Offers.Prod_ID), avg(Tb_Requests.Prod_ID), avg(Tb_Transactions.Prod_ID)
FROM Tb_Products,Tb_Offers,Tb_Requests,Tb_Transactions
WHERE Tb_Products.Prod_ID = Tb_Offers.Prod_ID
and Tb_Products.Prod_ID = Tb_Requests.Prod_ID
and Tb_Products.Prod_ID = Tb_Transactions.Prod_ID ;
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.