Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For each question, write the SQL query that would display the information asked by the question. For each question what is also shown is information

For each question, write the SQL query that would display the information asked by the question. For each question what is also shown is information that should be displayed by your SQL query: In other words, the table shown in the question is the output your query should produce should it be executed.

  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, but only for those parts for which the average quantity on order is greater than the average quantity on order over all parts. 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)

P3

3

1000

200

333.3333

400

246.1538

P2

4

1000

200

250.0000

400

246.1538

  1. Find each part for which its largest individual order in terms of quantity is larger than the largest quantity on order for either nut or a cam. and the largest quantity for a nut and the largest quantity for a cam.

PNO

MAX(qty)

MAXnutORcam

P2

400

300

P3

400

300

  1. Find each order for a part that is larger or equal to the average order for that part. Display, in an ascending order by part number, the part number, part name, quantity and the average quantity on order for that part

PNO

qty

AVG(qty)

P1

300

233.3333

P1

300

233.3333

P2

400

250.0000

P3

400

333.3333

P3

400

333.3333

P4

200

200.0000

P4

200

200.0000

P5

100

100.0000

9. As above, but also display the part name.

PNO

qty

AVG(qty)

PNAME

P1

300

233.3333

NUT

P1

300

233.3333

NUT

P2

400

250.0000

BOLT

P3

400

333.3333

SCREW

P3

400

333.3333

SCREW

P4

200

200.0000

SCREW

P4

200

200.0000

SCREW

P5

100

100.0000

CAM

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

Database Design Application Development And Administration

Authors: Mannino Michael

5th Edition

0983332401, 978-0983332404

More Books

Students also viewed these Databases questions