Question

Write the following four queries in MySQL using the supplies database. Please make sure to submit...

Write the following four queries in MySQL using the supplies database. Please make sure to submit a screenshot of the output of each of your query. (100 points)
1. Find the sids of suppliers who charge more for some part than the average cost of that part (averaged over all the suppliers who supply that part).
2. For each part, find the sname of the supplier who charges the most for that part.
3. Find the sids of suppliers who supply a red part and a green part.
4. For every supplier that only supplies red parts, print the name of the supplier and the total number of parts that they supply.

Homework Answers

Answer #1

1.

Select Supplier.sid from Supplier inner join SP on Supplier.sid = SP.sid inner join Part on SP.pid = Part.pid group by Supplier.sid having price> avg(price);

2.

Select sname from Supplier inner join SP on Supplier.sid = SP.sid inner join Part on SP.pid = Part.pid group by Part.pid having price = max(price);

3.

Select Supplier.sid from Supplier inner join SP on Supplier.sid = SP.sid inner join Part on SP.pid = Part.pid group by Supplier.sid having Part.color = 'red' and part.color = 'green';

4.

Select sname,count(Parts.pid) from Supplier inner join SP on Supplier.sid = SP.sid inner join Part on SP.pid = Part.pid group by sname having Part.color = 'red' ;

Do ask if any doubt. Please upvote.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Relational Algebra (50 pts): Consider the following database schema that keeps track of Sailors, Boats and...
Relational Algebra (50 pts): Consider the following database schema that keeps track of Sailors, Boats and the boats reserved by sailors. Sailors(sid, sname, rating, age) Boatsbid, bname, color) Reserves(sid, bid, date) Keys are underlined in each relation. Specify the following queries in Relational Algebra using above database schema. (f) find the name of sailors with the highest rating (g) find the name and age of oldest sailors (h) find the age of youngest sailor for each rating level (i) find...
Using the Company database in Oracle, construct SQL queries for the following (note: I will make...
Using the Company database in Oracle, construct SQL queries for the following (note: I will make the files to create and populate the Company database available on Isadore shortly): List the last name and address of managers who have a dependent with the same first name as themselves. Retrieve the names of all employees who are directly supervised by ‘Franklin Wong’. Retrieve the names of employees in the Research department who work more than 20 hours per week on the...
SUPPLIER Sno Sname Status City s1 Smith 20 London s2 Jones 10 Paris s3 Blake 30...
SUPPLIER Sno Sname Status City s1 Smith 20 London s2 Jones 10 Paris s3 Blake 30 Paris s4 Clark 20 London s5 Adams 30 NULL PART Pno Pname Color Weight City p1 Nut Red 12 London p2 Bolt Green 17 Paris p3 Screw NULL 17 Rome p4 Screw Red 14 London p5 Cam Blue 12 Paris p6 Cog Red 19 London SHIPMENT Sno Pno Qty Price s1 p1 300 .005 s1 p2 200 .009 s1 p3 400 .004 s1 p4...
Please read the article and answear about questions. Determining the Value of the Business After you...
Please read the article and answear about questions. Determining the Value of the Business After you have completed a thorough and exacting investigation, you need to analyze all the infor- mation you have gathered. This is the time to consult with your business, financial, and legal advis- ers to arrive at an estimate of the value of the business. Outside advisers are impartial and are more likely to see the bad things about the business than are you. You should...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary...
Please answer the following Case analysis questions 1-How is New Balance performing compared to its primary rivals? How will the acquisition of Reebok by Adidas impact the structure of the athletic shoe industry? Is this likely to be favorable or unfavorable for New Balance? 2- What issues does New Balance management need to address? 3-What recommendations would you make to New Balance Management? What does New Balance need to do to continue to be successful? Should management continue to invest...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT