• Status: Solved
• Priority: Medium
• Security: Public
• Views: 572

# SQL Query HELP!!

Based off of the following:

CUSTOMER (CUST_ID(PRI-KEY), CUST_NAME,ANNUAL_REVENUE, CUST_TYPE)
SHIPMENT (SHIPMENT_#(PRI-KEY), CUST_ID(PRI-KEY),WEIGHT, TRUCK_#, DESTINATION, SHIP_DATE)
TRUCK (TRUCK_#(PRI-KEY), DRIVER_NAME)
CITY (CITY_NAME(PRI-KEY), POPULATION)

What would the SQL Queries be - based on the following questions??

What is the name of customer 433?

What is the destination city of shipment #3244?

NOT EXISTS:
List customers who have had shipments delivered by every truck.

Built-in Functions:
What is the average weight of a shipment?

What is the average weight of a shipment going to Atlanta?

GROUP BY and HAVING:
For each customer, what is the average weight of a package
(shipment) sent by that customer?

0
mapper
• 2
• 2
1 Solution

Commented:
I believe the following will work for you:
Select Cust_Name from Customer where Cust_ID = 433;
Select Destination from Shipment where Shipment_# = 3244;
Select CustID where Count(Distinct(Truck_#)) in
(Select Count(Truck_#) from Truck)
Group by CustID;
Select Shipment_#, Avg(Weight) from Shipment;
Select Shipment_#, Avg(Weight) from Shipment Where Destination = 'Atlanta';
Select C.Cust_ID, avg(S.Weight) from Customer C, Shipment S
Where C.Cust_ID = S.Cust_ID;

0

Author Commented:
RSellis;

That's it?  No inner joins or anything like that?

mapper
0

Commented:
The last query is an inner join and the one about the truck is a sub-select but the rest seem pretty simple
Rick
0

Author Commented:
Rick,

Thanks - I appreciate it...

mapper
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.