Solved

SQL Query HELP!!

Posted on 1998-12-02
4
530 Views
Last Modified: 2008-03-06
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
Comment
Question by:mapper
  • 2
  • 2
4 Comments
 

Accepted Solution

by:
rsellis earned 200 total points
ID: 1969959
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 Comment

by:mapper
ID: 1969960
RSellis;

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

mapper
0
 

Expert Comment

by:rsellis
ID: 1969961
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 Comment

by:mapper
ID: 1969962
Rick,

Thanks - I appreciate it...

mapper
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question