Given the relations below, write the following queries using SQL (5 points each)
ID: 3722176 • Letter: G
Question
Given the relations below, write the following queries using SQL (5 points each). Note that the tables contain sample records only and stored in these tables. do not represent all the possible records that could be MEMB ERS MEMBER ID NAME Brooks Smith Brown Jones ADDRESS 1 Main Street 2 Main Street 3 Main Street 4 Main Street BALANCE 9.50 30.00 0.00 10.00 4 ORDERS ORDER NO MEMBER ID SNO ITEM Vegetable Oil Flour Cauliflower UANTITY 10 4 4 4 4 Lettuce Flour Flour Sugar Vegetable Oil SUPPLIERS SNAME A Produce B Supply C Inc SNO CITY Chica Oak Park ChicaExplanation / Answer
1. SELECT NAME FROM MEMBERS WHERE MEMBER_ID
IN(SELECT MEMBER_ID FROM ORDERDS WHERE ITEM IS SUGAR AND QUANTITY>=3)
2. SELECT NAME FROM MEMBERS WHERE MEMBER_ID
IN(SELECT MEMBER_ID FROM ORDERS,SUPPLIERS WHERE ORDERS.SNO =SUPPLIERS.SNO AND SUPPLIERS.CITY ='Chicago')
3.SELECT NAME FROM MEMBERS WHERE MEMBER_ ID NOT IN( SELECT MEMBER_ID FROM ORDERS)
4.SELECT NAME FROM MEMBERS WHERE MEMBER_ID IN( SELECT MEMBER_ID FROM ORDERS AS T1,SUPPLIER_ITEM AS T2 WHERE T1.ITEM = T2.ITEM
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.