You are on page 1of 2

1 List the Owner Number, Last Name, and First Name of every boat owner.

2 List the Last Name and First Name of every boat owner who lives in Bowton.
3 List the Last Name, First Name, and City of every boat owner who does not live in Bowton.
4 List the Marina Number, Slip Number, Boat Name, and Length for every slip whose length is
less than or equal to 30 feet. Sort the list in descending length.
5 List the Slip Number, Boat Name, and Marina Number of every boat located in Marina 2 with
Type like Dolphin.
6 List the Marina and Slip Number for all slips containing a boat with the Type Sprite 4000,
Sprite 3000, or Ray 4025.
7 How many Ray type boats are stored in both marinas? Format your result header as
COUNT_OF_BOATS.
8 List the Slip ID, Description, Estimated Hours, and Spent Hours of all service requests where
the estimated hours are between 2 and 6. Order the results by descending Spent Hours.
9 List the Slip ID and the total of the Estimated Hours for each item in the SERVICE_REQUEST
table. List only the Slips that have more than 7 total Estimated Hours, and rename the
aggregated function ESTIMATE_HOURS.
10 List the average length of all boats in each Marina. Your results should list each Marina and
the average of all boats as AVERAGE_LENGTH.
11 EXTRA CREDIT (worth additional 7pts): The Marina charges $50 per hour for labor. Using
the estimated hours in the SERVICE_REQUEST table, list the Category Number and the
product of all hours within that category group. Name the calculated column ESTIMATE_PAY.
=== #1 ===
SELECT OWNER_NUM, LAST_NAME, FIRST_NAME FROM OWNER
=== #2 ===
SELECT LAST_NAME, FIRST_NAME FROM OWNER WHERE (CITY = 'Bowton')
=== #3 ===
SELECT LAST_NAME, FIRST_NAME, CITY FROM OWNER WHERE (CITY <> 'Bowton')
==== # XXXXX ====
SELECT MARINA_NUM, SLIP_NUM, BOAT_NAME, LENGTH
FROM MARINA_SLIP
WHERE (LENGTH <= 30)
ORDER BY LENGTH DESC
===#5====
SELECT SLIP_NUM, BOAT_NAME, MARINA_NUM
FROM MARINA_SLIP
WHERE (MARINA_NUM = '2') AND (BOAT_TYPE LIKE 'Dolphin%')
=== #6 ===
SELECT SLIP_NUM, MARINA_NUM
FROM MARINA_SLIP
WHERE (BOAT_TYPE IN ('Sprite 4000', 'Sprite 3000', 'Ray 4025'))
=== #7 ====

SELECT COUNT(SLIP_ID) AS COUNT_OF_BOATS


FROM MARINA_SLIP
WHERE (BOAT_TYPE LIKE 'Ray%')
=== #8 ===
SELECT SLIP_ID, DESCRIPTION, EST_HOURS, SPENT_HOURS
FROM SERVICE_REQUEST
WHERE (SPENT_HOURS BETWEEN 2 AND 6)
ORDER BY SPENT_HOURS DESC
==== # XXXXX ====
SELECT SLIP_ID, SUM(EST_HOURS) AS ESTIMATED_HOURS
FROM SERVICE_REQUEST
GROUP BY SLIP_ID
HAVING (SUM(EST_HOURS) > 7)
==== # XXXXX =====
SELECT MARINA.NAME, AVG(MARINA_SLIP.LENGTH) AS AVERAGE_LENGTH
FROM MARINA INNER JOIN
MARINA_SLIP ON MARINA.MARINA_NUM = MARINA_SLIP.MARINA_NUM
GROUP BY MARINA.NAME
And...here is the extra credit answer:
SELECT CATEGORY_NUM, SUM(EST_HOURS * 50) AS EST_PAY
FROM SERVICE_REQUEST
GROUP BY CATEGORY_NUM

You might also like