1 answer

Questions in this part ask you to write SQL queriesthat would retrieve certain information from the...

Question:

Questions in this part ask you to write SQL queriesthat would retrieve certain information from the tables.

For each question, write the SQL query that would display the information asked by the question.

  1. Display information about parts that have their weights greater than the average weight of all parts.  

PNO

PNAME

P2

BOLT

P3

SCREW

  1. Find supplier numbers who supply any screws (i.e., such that the part name is ‘screw’).  The constraint is that you may not use any join or cross (product).  (Hint: Use subquery(ies).)

SNO

S1

S3

S4

S5

  1. Find supplier numbers of suppliers located in London who supply screws (i.e., such that the part name is ‘screw’) or bolts.  The constraint is that you may not use any join or product, but use a subquery(ies). (Hint: Use subquery(ies).)

SNO

S1

S2

S4

  1. Display the total number of orders (over all parts) and the minimum, average, and maximum quantity of individual orders (each order is a tuple in sp).

COUNT(PNO)

SUM(qty)

MIN(qty)

AVG(qty)

MAX(qty)

13

3200

100

246.1538

400

  1. For each part find the total, minimum, average, and maximum quantity of individual orders (each order is a tuple in p) and the total number of orders. Display the part number and for that part: the number of orders, total, minimum, average, maximum quantity of individual orders for that part and also the average quantity on order over all parts. Furthermore, display information in reverse order by part number.

PNO

COUNT(PNO)

SUM(qty)

MIN(qty)

AVG(qty)

MAX(qty)

AVG(qty)

P5

1

100

100

100.0000

100

246.1538

P4

2

400

200

200.0000

200

246.1538

P3

3

1000

200

333.3333

400

246.1538

P2

4

1000

200

250.0000

400

246.1538

P1

3

700

100

233.3333

300

246.1538

S                                                                              P

sNo (PK)

sName

sStatue

sCity

S1

Smith

20

London

S2

Jones

10

London

S3

Blake

30

Paris

S4

Clark

20

London

S5

Adams

30

Athens

pNo (PK)

pName

pColor

pWeight

P1

Nut

Red

12

P2

Bolt

Blue

17

P3

Screw

Green

17

P4

Screw

Red

14

P5

Cam

Blue

12

SP

sNo (PK) (FK)

pNo (PK) (FK)

qty

S1

P1

300

S1

P2

200

S1

P3

400

S1

P4

200

S1

P5

100

S2

P1

300

S2

P2

400

S3

P1

100

S3

P2

200

S3

P3

200

S4

P2

200

S4

P3

400

S5

P4

200

Figure 2.  Content of the Supplier-Parts DB Tables

                                   


Answers

If you have any doubts, please give me comment...

1)

SELECT PNO, PNAME

FROM P

WHERE pWeight>(

SELECT AVG(pWeight)

FROM P

);

2)

SELECT SNO

FROM S

WHERE sNo IN(

SELECT sNo

FROM SP

WHERE pNo IN(

SELECT pNo

FROM P

WHERE pName = 'Screw'

)

);


3)

SELECT SNO

FROM S

WHERE sCity = 'London' AND sNo IN(

SELECT sNo

FROM SP

WHERE pNo IN(

SELECT pNo

FROM P

WHERE pName = 'Screw' OR pName ='Bolt'

)

);


4)

SELECT COUNT(PNo), SUM(qty), MIN(qty), AVG(qty), MAX(qty)

FROM SP;

5)

SELECT COUNT(PNo), SUM(qty), MIN(qty), AVG(qty), MAX(qty)

FROM SP

GROUP BY PNo

ORDER BY PNo DESC;

.

Similar Solved Questions

1 answer
Explain the Following in Detail (1) If X~F[n, m], Y =*~F[m, n].- (2) If T~t[n], T2~F[1,...
Explain the Following in Detail (1) If X~F[n, m], Y =*~F[m, n].- (2) If T~t[n], T2~F[1, n]....
1 answer
2 The figure shows in creste, three conductors that carry ens perpendicular to the plame of...
2 The figure shows in creste, three conductors that carry ens perpendicular to the plame of the figure. If the Is and all have the same magnitude, for which puthi re the line integral of the magnetic field equal to ha banda e handd dged her the integral goes clockwise or counterclockwise around the ...
1 answer
End-Stage Renal Disease Case Study KB is a 42-year-old woman presenting to her primary care provider’s office for a rout...
End-Stage Renal Disease Case Study KB is a 42-year-old woman presenting to her primary care provider’s office for a routine well visit and discuss a possible kidney transplant. She has a past medical history (PMHx) of Stage 4 chronic kidney disease (CKD), diabetes mellitus type1, and hypertens...
1 answer
Issue on an individual asset - what is the expected return, variance and standard deviation of...
issue on an individual asset - what is the expected return, variance and standard deviation of asset A only I WA TISK and fetui11 man those that are provided in the article. The table below gives information on three risky assets: A, B, and C. Correlations Asset Expected return Standard Deviation o...
1 answer
The cantilever, shown, has a steel core bonded to a wood casing. If a concentrated load...
The cantilever, shown, has a steel core bonded to a wood casing. If a concentrated load 25 kN is applied at its end, determine the maximum bending stress in the cantilever. E.-12 GPa, E,- 200 GPA. 25 kN 3.00 m 200 mm 200 mm 500 mm Steel 500 m Cross section of the cantilever...
1 answer
Q2 (15) Suppose we suspect a coin is not fair – we suspect that it has...
Q2 (15) Suppose we suspect a coin is not fair – we suspect that it has larger chance of getting tails than heads, so we want to conduct a hypothesis testing to investigate this question. a:(4 pts) Let p be the chance of getting heads, write down the alternative hypothesis H, and the null hypot...
1 answer
Dwelling un 4. Type NM-B Cable enters a metal device box and is secured by a cable clamp at the bottom of the box....
dwelling un 4. Type NM-B Cable enters a metal device box and is secured by a cable clamp at the bottom of the box. The cable is installed so the cable jacket extends "1/4 in. (6 mm beyond the cable clamp and free conductors begin at the end of the cable jacket a shown in Figure 1.39. If the devi...
1 answer
Tangent line
Find all the values of x where the tangent line is horizontalf(x) = 2x3+39x2+252x+4 (use a comma to separate answers as needed)...
1 answer
Two cables tied together at C are loaded as shown. Knowing that the maximum allowable tension...
Two cables tied together at C are loaded as shown. Knowing that the maximum allowable tension in each cable is 650 N, determine (a) the magnitude of the largest force P which may be applied at C, (b) the corresponding value of a....
1 answer
Empathy means being able to understand what others feel. To see how the brain expresses empathy,...
Empathy means being able to understand what others feel. To see how the brain expresses empathy, researchers recruited 16 couples in their midtwenties who were married or had been dating for at least two years. They zapped the man's hand with an electrode while the woman watched, and measured th...
1 answer
Homework: Chapter 10 Homework Save Score: 0 of 1 pt 4 of 8 (0 complete) HW...
Homework: Chapter 10 Homework Save Score: 0 of 1 pt 4 of 8 (0 complete) HW Score: 0%, 0 of 8 pts P10-5 (similar to) Question Help O Working capital cash flow. Cool Water, Inc. sells bottled water. The firm keeps in inventory plastic bottles at 12% of the monthly projected sales. These plastic bottle...
1 answer
3 and 4
Three masses are arranged in the (x, y)plane as shown.the 5kg is at the origin (0,0), the 3kg is at (5,0) and the 4kg is at (2,-4)What is the magnitude of the result-ing force on the 5 kg mass at the ori-gin? The universal gravitational constant is6.6726 × 10-11 N · m2/kg2 .Answer in un...
1 answer
Journal entry worksheet 2 3 Business Sim Corp. (BSC) issued 2,000 common shares to Kelly in...
Journal entry worksheet 2 3 Business Sim Corp. (BSC) issued 2,000 common shares to Kelly in exchange for $27,000. Record the transaction. Note: Enter debits before credits. Transaction General Journal Debit Credit Record entry Clear entry View general journal...
1 answer
Peer Lender: Weekly Assessment ? For questions 13. determine the electron configuration of each element. 1....
Peer Lender: Weekly Assessment ? For questions 13. determine the electron configuration of each element. 1. Na 3. Zn 4. Give then and values for the following orbitals. (b) Is 5. Circle one of the following electron configurations that is ruled out by the Pauli exclusion principle (10 pt) and explai...
1 answer
Mountain Excursions issues bonds due in 12 years with a stated interest rate of 12% and...
Mountain Excursions issues bonds due in 12 years with a stated interest rate of 12% and a face value of $120,000. Interest payments are made semi-annually. The market rate for this type of bond is 13%. Using a financial calculator or Excel, calculate the issue price of the bonds. A) 70,292 B) 112,80...
1 answer
On January 1, 2020, the Hardin Company budget committee has reached agreement on the following data...
On January 1, 2020, the Hardin Company budget committee has reached agreement on the following data for the months ending June 30, 2020. Sales units: First quarter 6,000 second quarter 6.900: third quarter 7400 Ending raw materials inventory: 40% of the next quarter's production requirements End...
1 answer
You find the following corporate bond quotes. To calculate the number of years until maturity, assume...
You find the following corporate bond quotes. To calculate the number of years until maturity, assume that it is currently January 15, 2019 and the bonds have a par value of $2,000. Company (Ticker) Coupon Maturity Last Price Last Yield EST $ Vol (000’s) Xenon, Inc. (XIC) 6.000 Jan 15, 2029 94...
1 answer
The following data from the just completed year are taken from the accounting records of Mason...
The following data from the just completed year are taken from the accounting records of Mason Company: Sales Direct labor cost Raw material purchases Selling expenses Administrative expenses Manufacturing overhead applied to work in process Actual manufacturing overhead costs s 654,000 $ 81,000 135...
1 answer
Gasoline Brands 21 20 24 30 Automobiles 29 25 23 24 24 20 a. At a- 05, is there a significant difference in the...
Gasoline Brands 21 20 24 30 Automobiles 29 25 23 24 24 20 a. At a- 05, is there a significant difference in the mean miles-per-gallon chaacteris- tics of the three brands of gasoline? b. Analyze the experimental data using the ANOVA procedure for completely random- ized designs. Compare your finding...
1 answer
The total mass of an iron atom is smaller than the total of the masses of...
The total mass of an iron atom is smaller than the total of the masses of the protons, neutrons, and electrons that make up the atom. Where did the missing mass go?...