Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please Help in SQL . Give the top 2 and bottom 2 parts supplied based on their total shipped quantity. Your result will include part#,

  1. Please Help in SQL .

  2. Give the top 2 and bottom 2 parts supplied based on their total shipped quantity. Your result will include part#, Total_QTY, Top_2, Bottom_2

  3. Give the supplier#, supplier_name that supplies the maximum total quantity for all parts.

  4. Give the name of the supplier whose supplies red parts and whose weight > 10. Your result will include supplier number and supplier name

  5. Give unique pair of part numbers that are from the same city

  6. Give the supplier number and part numbers that are located in the same city

  7. Give the part name and number that has the minimum shipped quantity

  8. Give how many parts each supplier has and the total qty each part has.

  9. What is the total number of shipped parts for each part color part. Your result will include: Color, total_QTY_Shipped

  10. Give the total quantity of all the blue parts or yellow parts

  11. Give the suppliers that are not from the city from which smith is.

  12. How many parts are shipped using the following Ranges. Range between 0-100, Range between 101-300, Range between 301 to 500, Range > 501. Your result will include: Range, number of parts

  13. Give the top and bottom suppliers based on the quantity they supply.

  14. Give the top 3 parts that weigh the most.

  15. Give all the parts that are not from London and whose color is not blue

  16. Give the total quantity supplied by each supplier and supplier name

  17. Give the name of the supplier that does not supply a red part.

  18. Give the name of parts from supplier from Paris with qty>100 and part is from Paris

  19. Give the total weight of all the red parts

  20. Give the names of the suppliers that are from the same city

  21. Give the supplier name that supplies the minimum quantity of parts

  22. Give the total quantity present for each part

  23. Give the part name that has the maximum quantity

  24. Give the suppliers and parts that come from the London

  25. Give the total qty for all the parts

  26. Give the max number of parts supplied by a supplier

  27. Give the name of parts from supplier from London with qty>100 and part is from London

  28. Give the name of the supplier that supplies both red part and weight is 14.

  29. Rank suppliers on the total quantity and number of parts

  30. Give the subtotals of the total part weights of the all the parts supplied by a supplier and give the final total weight.

  31. What is the percentage of total shipments from each supplier

  32. For each part color, list the top two suppliers with highest qty shipped.

  33. What is the top one third of shipments. List supplier number and qty.

  34. image text in transcribed

-- This tables drops and recreates the table for the SPJ database DROP TABLE S; DROP TABLE P; DROP TABLE SP; CREATE TABLE SC S# VARCHAR(2) NOT NULL, SNAME VARCHAR(5), STATUS NUMBER(2), CITY VARCHAR(6), CONSTRAINT S_S#_PK PRIMARY KEY (S#)); CREATE TABLE PC P# VARCHAR(2) NOT NULL, PNAME VARCHAR(5), COLOR VARCHAR(5), WEIGHT FLOAT, CITY VARCHAR(6), CONSTRAINT P_P#_PK PRIMARY KEY(P#); CREATE TABLE SP S# VARCHAR(2) NOT NULL, P# VARCHAR(2) NOT NULL, QTY NUMBER(3), CONSTRAINT SP_S#_P#_PK PRIMARY KEY (S#, P#), CONSTRAINT SP_S#_FK FOREIGN KEY (S#) REFERENCES S(S#), CONSTRAINT SP_P#_FK FOREIGN KEY (P#) REFERENCES P(P#) ); grant select on S to public; grant select on P to public; grant select on SP to public; insert into s values( '51','Smith',20, 'London'); insert into s values( 'S2', 'Jones',10,'Paris'); insert into s values ( '53', 'Black',30,'Paris'); insert into s values( '54', 'Clark',20, 'London'); insert into s values 'S5', 'Adams', 30, 'Athens'); insert into p values( 'Pi', 'Nut', 'Red', 12, 'London'); insert into p values( 'P2', 'Bolt', 'Green',17, 'Paris'); insert into p values ( 'P3', 'Screw', 'Blue',17, 'Rom'); insert into p values( 'P4', 'Screw', 'Red', 14, 'London'); insert into p values( 'P5', 'Cam', 'Blue',12, 'Paris'); insert into p values ( 'P6','Cog', 'Red', 19, 'London'); insert into sp values ( 'Si', 'P1',300); insert into sp values ('51','P2',200); insert into sp values ( '51','P3',400); insert into sp values ( '51','P4',200); insert into sp values ( '51','P5',100); insert into sp values ('51','P6',100); insert into sp values ( '52','Pi',300); insert into sp values ( '52', '22',400); insert into sp values ( '53','P2',200); insert into sp values ( '54', 'P2',200); insert into sp values ( 'S4', 'P4', 300); insert into sp values ( '54', '25',400); -- This tables drops and recreates the table for the SPJ database DROP TABLE S; DROP TABLE P; DROP TABLE SP; CREATE TABLE SC S# VARCHAR(2) NOT NULL, SNAME VARCHAR(5), STATUS NUMBER(2), CITY VARCHAR(6), CONSTRAINT S_S#_PK PRIMARY KEY (S#)); CREATE TABLE PC P# VARCHAR(2) NOT NULL, PNAME VARCHAR(5), COLOR VARCHAR(5), WEIGHT FLOAT, CITY VARCHAR(6), CONSTRAINT P_P#_PK PRIMARY KEY(P#); CREATE TABLE SP S# VARCHAR(2) NOT NULL, P# VARCHAR(2) NOT NULL, QTY NUMBER(3), CONSTRAINT SP_S#_P#_PK PRIMARY KEY (S#, P#), CONSTRAINT SP_S#_FK FOREIGN KEY (S#) REFERENCES S(S#), CONSTRAINT SP_P#_FK FOREIGN KEY (P#) REFERENCES P(P#) ); grant select on S to public; grant select on P to public; grant select on SP to public; insert into s values( '51','Smith',20, 'London'); insert into s values( 'S2', 'Jones',10,'Paris'); insert into s values ( '53', 'Black',30,'Paris'); insert into s values( '54', 'Clark',20, 'London'); insert into s values 'S5', 'Adams', 30, 'Athens'); insert into p values( 'Pi', 'Nut', 'Red', 12, 'London'); insert into p values( 'P2', 'Bolt', 'Green',17, 'Paris'); insert into p values ( 'P3', 'Screw', 'Blue',17, 'Rom'); insert into p values( 'P4', 'Screw', 'Red', 14, 'London'); insert into p values( 'P5', 'Cam', 'Blue',12, 'Paris'); insert into p values ( 'P6','Cog', 'Red', 19, 'London'); insert into sp values ( 'Si', 'P1',300); insert into sp values ('51','P2',200); insert into sp values ( '51','P3',400); insert into sp values ( '51','P4',200); insert into sp values ( '51','P5',100); insert into sp values ('51','P6',100); insert into sp values ( '52','Pi',300); insert into sp values ( '52', '22',400); insert into sp values ( '53','P2',200); insert into sp values ( '54', 'P2',200); insert into sp values ( 'S4', 'P4', 300); insert into sp values ( '54', '25',400)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Relational Model A Retrospective Review And Analysis

Authors: C. J. Date

1st Edition

0201612941, 978-0201612943

Students also viewed these Databases questions