Chapter 9 minicases Happy Cruise Lines a. Find the start and end dates of cruise number 35218. select startdate, enddate from cruise where cruisenum = 35218; 9-2 startdate enddate ٢٠٠٤/٥/١٥ ٢٠٠٤/٥/٢٩ 9-3 Happy Cruise Lines b. List the names and ship numbers of the ships built by the Ace Shipbuilding Corp. that weigh more than 60,000 tons. select shipnum, shipname from ship where builder = 'Ace Shipbuilding Corp.' and weight > 60000; 9-4 shipnum shipname ٠٢٢ Pacific Blue 9-5 Happy Cruise Lines c. List the company’s that have built ships for Happy Cruise Lines. Select distinct builder From ship; 9-6 Happy Cruise Lines d. Find the total number of docks in all of the ports in Canada. Select sum(numdocks) From port Where country = ‘Canada’; 9-7 Happy Cruise Lines e. Find the average weight of the ships built by the Ace Shipbuilding Corp. that have been launched since 2000. Select avg(weight) From ship Where builder = ‘Ace Shipbuilding Corp.’ and launchdate >= ‘JAN-01-2000’; 9-8 Happy Cruise Lines f. How many ports in Venezuela have at least three docks? Select count(*) From port Where country = ‘Venezuela’ and numdocks >= 3; 9-9 Happy Cruise Lines g. Find the total number of docks in each country. List the results in order from most to least. Select country, sum(numdocks) From port Group by country Order by sum(numdocks) DESC; 9-10 Happy Cruise Lines h. Find the total number of ports in each country. Select country, count(*) From port Group by country; 9-11 Happy Cruise Lines i. Find the total number of docks in each country but only include those countries that have at least twelve docks in your answer. Select country, sum(numdocks) From port Group by country Having sum(numdocks) >= 12; 9-12 Happy Cruise Lines j. Find the name of the ship that operated on (was used on) cruise number 35218. Select shipname From ship, cruise Where ship.shipnum = cruise.shipnum and cruisenum = 35218; 9-13 Happy Cruise Lines k. List the names, addresses, and telephone numbers of the passengers who sailed on The Spirit of Nashville on cruises that began during July, 2003 . Select passengername, address, phone From passenger, voyage, cruise, ship Where passenger.passengernum = voyage.passengernum and voyage.cruisenum = cruise.cruisenum and cruise.shipnum = ship.shipnum and shipname = ‘The Spirit of Nashville’ and startdate between ‘JUL-01-2003’9-14 and ‘JUL-31-2003’; Happy Cruise Lines l. Find the names of the company’s heaviest ships. Select shipname From ship Where weight = (select max(weight) from ship); 9-15 Happy Cruise Lines m. Find the names of the company’s heaviest ships that began a cruise between July 15, 2003 and July 31, 2003. Select shipname From ship, cruise Where ship.shipnum = cruise.shipnum and startdate between ‘JUL-15-2003’ and ‘JUL-31-2003’ and weight = (select max(weight) from ship, cruise where ship.shipnum = cruise.shipnum and startdate between ‘JUL-15-2003’ 9-16 and ‘JUL-31-2003’); Super Baseball League a. Find the names and cities of all of the teams with team numbers greater than 15. List the results alphabetically by team name. select teamname, city from team where teamnum > 15 order by teamname; 9-17 teamname city Tigers Detroit Yankees New York 9-18 Super Baseball League For MS Access: b. List all of the coaches whose last names begin with “D” and who have between 5 and 10 years of experience as college coaches (see YEARSEXPERIENCE and EXPERIENCETYPE). select coachname from [work experience] where coachname like 'D*' and experiencetype = 'College Coach' and yearsexperience between 5 and 10; 9-19 teamnum coachname ٢٤ Dooley 9-20 Super Baseball League c. Find the total number of years of experience of coach Taylor on team number 23. Select sum(yearsexperience) From [work experience] Where teamnum = 23 and coachname = ‘Taylor’; 9-21 Super Baseball League d. Find the number of different types of experience that coach Taylor on team number 23 has. Select count(*) From [work experience] Where teamnum = 23 and coachname = ‘Taylor’; 9-22 Super Baseball League e. Find the total number of years of experience of each coach on team number 23. For MS Access: Select sum(yearsexperience) From [work experience] Where teamnum = 23 Group by coachname; 9-23 Super Baseball League f. How many different manufacturers make bats for the league’s teams? Select count(distinct manufacturer) From bats; 9-24 MS Access 不支援 Select Count distinct 的語法, 要做這樣的查詢必須使用「子查詢」如下: 以 Cruise 資料庫為例, 要使用 Select count (country) From (Select distinct country from visit); 不能使用 Select count (distinct country) from Visit; 9-25 Super Baseball League g. Assume that team names are unique. Find the names of the players who have played for the Dodgers for at least five years (see YEARS in the affiliation table.) Select playername From player, affiliation, team Where player.playernum = affiliation.playernum and affiliation.teamnum = team.teamnum and teamname = ‘Dodgers’ and years >= 5; 9-26 Super Baseball League h. Assume that team names are unique. Find the total number of years of work experience of each coach on the Dodgers, but only include in the result those coaches who have more than eight years of experience. Select coachname, sum(yearsexperience) From team, [work experience] Where team.teamnum = [work experience].teamnum and teamname = ‘Dodgers’ Group by coachname Having sum(yearsexperience) > 8; 9-27 Super Baseball League i. Find the names of the league's youngest players. Select playername From player Where age = (select min(age) from player); 9-28 Super Baseball League j. Find the names of the league’s youngest players whose last names begin with the letter “B”. Select playername From player Where playername like ‘B*’ And age = (select min(age) from player where playername like ‘B*’); 9-29
© Copyright 2026 Paperzz