Question: *** SQL Databases. Please be concise and show full explanation. Please help. Show your own work. Has to run on Oracle SQL Developer. *** (a)
*** SQL Databases. Please be concise and show full explanation. Please help. Show your own work. Has to run on Oracle SQL Developer. ***

(a) 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).
(b) Find the sids of suppliers who supply a red part and a green part.
(c) For every supplier that only supplies green parts, print the name of the supplier and the total number of parts that it supplies.
Here are the tables to work with each part:
create table suppliers( sid number(9,0) primary key, sname varchar2(30), address varchar2(40) ); create table parts( pid number(9,0) primary key, pname varchar2(40), color varchar2(15) ); create table catalog( sid number(9,0), pid number(9,0), cost number(10,2), primary key(sid,pid), foreign key(sid) references suppliers, foreign key(pid) references parts );
The additions to the tables are the following: insert into suppliers (sid, sname, address) values (6, 'OnlyGreen', 'GreenOnly'); insert into catalog (sid, pid, cost) values (6, 9, 10.0); The Parts lists the colors with capital letters; so, your queries involving green or red need to use Red or Green, respectively.
Exercise 5.2 Consider the following schema: Suppliers (sid: integer, sname: string, address: string) Parts(pid: integer, pname: string, color: string) Catalog(sid: integer, pid: integer, cost: real) The Catalog relation lists the prices charged for parts by Suppliers. Write the following queries in SQL
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
