Question

Determine the company that has the greatest number of travel days out of all reservations. Display...

  1. Determine the company that has the greatest number of travel days out of all reservations. Display the name of the company and the total number of travel days with the header of SUMDAYS.


create table Customer(
customerID number,
firstName varchar2(15),
lastName varchar2(15),
address varchar2(30),
phone number(10) not null,
age number(3),
Constraint Customer_PK Primary Key (customerID),
constraint Customer_UQ unique (firstName,lastName,phone),
constraint Customer_CK check(phone is not null)
);

create sequence customerID_seq
start with 1
increment by 1;

insert into Customer values (customerID_seq.nextval, 'Dylan', 'Ward', '42 Elm Place', 8915367188, 22);
insert into Customer values (customerID_seq.nextval, 'Austin', 'Ross', '657 Redondo Ave.', 1233753684, 25);
insert into Customer values (customerID_seq.nextval, 'Lisa', 'Powell', '5 Jefferson Ave.', 6428369619, 17);
insert into Customer values (customerID_seq.nextval, 'Brian', 'Martin', '143 Cambridge Ave.', 5082328798, 45);
insert into Customer values (customerID_seq.nextval, 'Nicole', 'White', '77 Massachusetts Ave.', 6174153059, 29);
insert into Customer values (customerID_seq.nextval, 'Tyler', 'Garcia', '175 Forest St.', 9864752346, 57);
insert into Customer values (customerID_seq.nextval, 'Anna', 'Allen', '35 Tremont St.', 8946557732, 73);
insert into Customer values (customerID_seq.nextval, 'Michael', 'Sanchez', '9 Washington Court', 1946825344, 18);
insert into Customer values (customerID_seq.nextval, 'Justin', 'Myers', '98 Lake Hill Drive', 7988641411, 26);
insert into Customer values (customerID_seq.nextval, 'Bruce', 'Clark', '100 Main St.', 2324648888, 68);
insert into Customer values (customerID_seq.nextval, 'Rachel', 'Lee', '42 Oak St.', 2497873464, 19);
insert into Customer values (customerID_seq.nextval, 'Kelly', 'Gray', '1414 Cedar St.', 9865553232, 82);
insert into Customer values (customerID_seq.nextval, 'Madison', 'Young', '8711 Meadow St.', 4546667821, 67);
insert into Customer values (customerID_seq.nextval, 'Ashley', 'Powell', '17 Valley Drive', 2123043923, 20);
insert into Customer values (customerID_seq.nextval, 'Joshua', 'Davis', '1212 8th St.', 7818914567, 18);

select * from Customer;

create table Company(
companyName varchar2(15),
stockSymbol char(4),
website varchar2(40),
Constraint Company_PK Primary Key (companyName),
Constraint Company_UQ unique(stockSymbol)
);

insert into Company values ('Carnival', 'CRVL', 'http://www.carnival.com');
insert into Company values ('Celebrity', 'CELB', 'http://www.celebritycruises.com');
insert into Company values ('NCL', 'NCLC', 'http://www.ncl.com');
insert into Company values ('Princess', 'PRCS', 'http://www.princess.com');

select * from Company;

create table TravelAgent(
travelAgentID number,
firstname varchar2(15),
lastname varchar2(20),
title varchar2(15),
salary number(7,2),
constraint TravelAgent_Pk primary key(travelAgentID),
constraint check_title check(title in ('Agent','Manager','Assistant'))
);

create sequence travelAgentID_seq
start with 1
increment by 1;

insert into TravelAgent values (travelAgentID_seq.nextval, 'Chloe', 'Rodriguez', 'Assistant' , 31750.00);
insert into TravelAgent values (travelAgentID_seq.nextval, 'Ben', 'Wilson', 'Agent' , 47000.22);
insert into TravelAgent values (travelAgentID_seq.nextval, 'Mia', 'Smith', 'Manager' , 75250.00);
insert into TravelAgent values (travelAgentID_seq.nextval, 'Noah', 'Williams', 'Assistant' , 32080.90);
insert into TravelAgent values (travelAgentID_seq.nextval, 'Liam', 'Brown', 'Manager' , 60500.75);
insert into TravelAgent values (travelAgentID_seq.nextval, 'Mason', 'Jones', 'Manager', 79000.00);
insert into TravelAgent values (travelAgentID_seq.nextval, 'Olivia', 'Miller', 'Agent' , 54000.50);
insert into TravelAgent values (travelAgentID_seq.nextval, 'Sofia', 'Davis', 'Agent' , 45000.00);
insert into TravelAgent values (travelAgentID_seq.nextval, 'Jason', 'Garcia', 'Manager' , 52025.95);
insert into TravelAgent values (travelAgentID_seq.nextval, 'Emily', 'Johnson', 'Assistant' , 22000.50);
insert into TravelAgent values (travelAgentID_seq.nextval, 'Ethan', 'Elm', 'Agent' , 27044.52);

select * from TravelAgent;

create table Ship(
shipName varchar2(30),
companyName varchar2(15),
yearBuilt number(4),
crew number(4),
passengers number(4),
tonnage number(6),
dailyTips number(5,2),
Constraint Ship_PK Primary Key(shipName),
Constraint Ship_FK Foreign Key (companyName) references Company(companyName),
Constraint Ship_CK Check (yearBuilt >= 1822),
Constraint Ship_TonCK Check (tonnage in (50000, 65000, 80000, 95000, 110000))
);


insert into Ship values ('Pearl','Carnival', 1997, 930, 2124, 95000, 9.95);
insert into Ship values ('Jewel','Celebrity', 2009, 1255, 2850, 95000, 15.50);
insert into Ship values ('Equinox','NCL', 2005, 1069, 2376, 50000, 12.75);
insert into Ship values ('Crown','NCL', 2006, 1072, 2394, 65000, 12.75);
insert into Ship values ('Spirit','Princess', 2018, 1200, 3080, 110000, 14.00);

select * from Ship;

create table Cruise(
cruiseID number,
cruiseName varchar2(25),
departurePort varchar2(20),
days number(2),
shipName varchar2(30),
companyName varchar2(15),
price number(7,2),
Constraint Cruise_PK Primary Key (cruiseID),
constraint Cruise_FK Foreign Key (shipName) References Ship(shipName) ON DELETE CASCADE
);

create sequence cruiseID_seq
start with 1
increment by 1;

insert into Cruise values (cruiseID_seq.nextval, 'Mexico', 'Miami', 7 , 'Pearl', 799.00);
insert into Cruise values (cruiseID_seq.nextval, 'New England', 'Boston', 7 , 'Jewel', 895.75);
insert into Cruise values (cruiseID_seq.nextval, 'ABC Islands', 'Miami', 4 , 'Equinox', 450.50);
insert into Cruise values (cruiseID_seq.nextval, 'Hawaii', 'San Francisco', 14 , 'Crown', 2310.00);
insert into Cruise values (cruiseID_seq.nextval, 'Panama Canal', 'Miami', 10 , 'Spirit', 1432.99);

select * from Cruise;

create table Reservation(
reservationID number,
customerID number,
cruiseID number,
travelAgentID number,
travelDate date,
paymentDate date default null,
constraint Reservation_PK primary key (reservationID),
Constraint Reservation_CustFK Foreign Key (customerID) References Customer (customerID) ON DELETE CASCADE ,
Constraint Reservation_CruFK Foreign Key (cruiseID) References Cruise (cruiseID) ON DELETE CASCADE,
Constraint Reservation_TraFK Foreign Key (travelAgentID) References TravelAgent (travelAgentID) ON DELETE CASCADE
);

create sequence reservationID_seq
start with 1
increment by 1;

insert into Reservation values (reservationID_seq.nextval, 12, 1, 2, '9-Nov-18',null);
insert into Reservation values (reservationID_seq.nextval, 14, 4, 5, '21-Jan-19',null);
insert into Reservation values (reservationID_seq.nextval, 5, 4, 1, '11-Dec-18',null);
insert into Reservation values (reservationID_seq.nextval, 9, 5, 4, '31-Aug-19',null);
insert into Reservation values (reservationID_seq.nextval, 13, 1, 2, '10-Apr-19',null);
insert into Reservation values (reservationID_seq.nextval, 5, 4, 6, '29-Jul-18',null);
insert into Reservation values (reservationID_seq.nextval, 2, 2, 2, '17-May-19',null);
insert into Reservation values (reservationID_seq.nextval, 4, 1, 10, '11-Apr-19',null);
insert into Reservation values (reservationID_seq.nextval, 10, 5, 3, '3-Jun-18',null);
insert into Reservation values (reservationID_seq.nextval, 5, 3, 9, '15-Oct-18',null);
insert into Reservation values (reservationID_seq.nextval, 1, 2, 7, '8-Mar-19',null);
insert into Reservation values (reservationID_seq.nextval, 5, 4, 7, '24-Nov-18',null);
insert into Reservation values (reservationID_seq.nextval, 8, 1, 1, '3-Aug-19',null);
insert into Reservation values (reservationID_seq.nextval, 15, 5, 10, '13-Dec-18',null);
insert into Reservation values (reservationID_seq.nextval, 4, 3, 7, '6-Feb-19',null);
insert into Reservation values (reservationID_seq.nextval, 6, 4, 5, '12-Aug-19',null);
insert into Reservation values (reservationID_seq.nextval, 14, 2, 8, '22-Jun-19',null);
insert into Reservation values (reservationID_seq.nextval, 11, 5, 9, '1-Feb-19',null);
insert into Reservation values (reservationID_seq.nextval, 7, 4, 8, '15-Mar-19',null);
insert into Reservation values (reservationID_seq.nextval, 14, 4, 3, '28-Feb-19',null);

select * from Reservation;

Please help answer the question

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If you have any doubts, please give me comment...

SELECT companyName, COUNT(DISTINCT travelDate) AS SUMDAYS

FROM Cruise AS C, Reservation AS R

WHERE C.cruiseID = R.cruiseID

GROUP BY companyName

HAVING COUNT(DISTINCT travelDate) >= ALL(

SELECT COUNT(DISTINCT travelDate)

FROM Cruise AS C1, Reservation AS R1

WHERE C1.cruiseID = R1.cruiseID

GROUP BY companyName

);

Let me know if you get any errors... Thank you...

Add a comment
Know the answer?
Add Answer to:
Determine the company that has the greatest number of travel days out of all reservations. Display...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need help for SQL homework. the question: the code for part 1,2: drop table Customer;...

    I need help for SQL homework. the question: the code for part 1,2: drop table Customer; drop table Company; drop table Cruise; drop table TravelAgent; drop table Reservation; drop sequence customerID_seq; drop sequence cruiseID_seq; drop sequence travelAgentID_seq; drop sequence reservationID_seq; create table Customer( customerID number, firstName varchar2(15), lastName varchar2(15), address varchar2(30), phone number(10) not null, age number(3), Constraint Customer_PK Primary Key (customerID), constraint Customer_unique unique (firstName,lastName,phone), constraint Customer_check check(phone is not null) ); create sequence customerID_seq start with 1 increment...

  • I am using oracle sql developer to create some queries to generated reports and it is...

    I am using oracle sql developer to create some queries to generated reports and it is not working. I am not sure how to use count, group by, and order by. Help me fix my query and explain to me how you did, so can do it next time. Also, I have to convert this query to a stored procedure, so can you help me do it too? Here is my query: SELECT COUNT(GUEST.FIRSTNAME), GUEST.FIRSTNAME, GUEST.LASTNAME, GUEST.GUESTTYPE, RESERVATION.RESERVATIONDATE, GUEST.EMAIL, FROM...

  • -- drop tables DROP TABLE REQUEST CASCADE CONSTRAINTS; DROP TABLE FULLORDER CASCADE CONSTRAINTS; DROP TABLE PRODUCT...

    -- drop tables DROP TABLE REQUEST CASCADE CONSTRAINTS; DROP TABLE FULLORDER CASCADE CONSTRAINTS; DROP TABLE PRODUCT CASCADE CONSTRAINTS; DROP TABLE CUSTOMER CASCADE CONSTRAINTS; -- create and link tables CREATE TABLE CUSTOMER (    CustomerID   INTEGER,    Name       VARCHAR2(40),    City       VARCHAR2(20),    State       CHAR(2),    Zip       CHAR(5),    CONSTRAINT PK_CUSTOMER        PRIMARY KEY (CustomerID) ); CREATE TABLE PRODUCT (    ProductID   INTEGER,    Description   VARCHAR2(30),    Material   VARCHAR2(20),    Price       NUMBER(5,2),    CONSTRAINT PK_PRODUCT...

  • Display all customers. If a customer has placed any orders, also display the highest..... Tables: CREATE TABLE Sales.Cu...

    Display all customers. If a customer has placed any orders, also display the highest..... Tables: CREATE TABLE Sales.Customers ( CustomerId          INT          NOT NULL IDENTITY, CustomerName          NVARCHAR(50) NOT NULL, StreetAddress NVARCHAR(50) NULL, City          NVARCHAR(20) NULL, [State]          NVARCHAR(20) NULL, PostalCode         NVARCHAR(10) NULL, Country          NVARCHAR(20) NULL, Contact          NVARCHAR(50) NULL, Email         NVARCHAR(50) NULL, CONSTRAINT PK_Customers PRIMARY KEY(CustomerId) ); CREATE TABLE HR.Employees ( EmployeeId          INT          NOT NULL IDENTITY, FirstName         NVARCHAR(50) NOT NULL, LastName          NVARCHAR(50) NOT NULL, BirthDate         DATE         NOT NULL, HireDate          DATE         NOT NULL, HomeAddress...

  • -- drop tables DROP TABLE REQUEST CASCADE CONSTRAINTS; DROP TABLE FULLORDER CASCADE CONSTRAINTS; DROP TABLE PRODUCT...

    -- drop tables DROP TABLE REQUEST CASCADE CONSTRAINTS; DROP TABLE FULLORDER CASCADE CONSTRAINTS; DROP TABLE PRODUCT CASCADE CONSTRAINTS; DROP TABLE CUSTOMER CASCADE CONSTRAINTS; -- create and link tables CREATE TABLE CUSTOMER (    CustomerID   INTEGER,    Name       VARCHAR2(40),    City       VARCHAR2(20),    State       CHAR(2),    Zip       CHAR(5),    CONSTRAINT PK_CUSTOMER        PRIMARY KEY (CustomerID) ); CREATE TABLE PRODUCT (    ProductID   INTEGER,    Description   VARCHAR2(30),    Material   VARCHAR2(20),    Price       NUMBER(5,2),    CONSTRAINT PK_PRODUCT...

  • Provide the syntax answers for the following script, doesn't matter what table or columns. CREATE TABLE...

    Provide the syntax answers for the following script, doesn't matter what table or columns. CREATE TABLE customer (c_id NUMBER(5), c_last VARCHAR2(30), c_first VARCHAR2(30), c_mi CHAR(1), c_birthdate DATE, c_address VARCHAR2(30), c_city VARCHAR2(30), c_state CHAR(2), c_zip VARCHAR2(10), c_dphone VARCHAR2(10), c_ephone VARCHAR2(10), c_userid VARCHAR2(50), c_password VARCHAR2(15), CONSTRAINT customer_c_id_pk PRIMARY KEY (c_id)); CREATE TABLE order_source (os_id NUMBER(3), os_desc VARCHAR2(30), CONSTRAINT order_source_os_id_pk PRIMARY KEY(os_id)); CREATE TABLE orders (o_id NUMBER(8), o_date DATE, o_methpmt VARCHAR2(10), c_id NUMBER(5), os_id NUMBER(3), CONSTRAINT orders_o_id_pk PRIMARY KEY (o_id), CONSTRAINT orders_c_id_fk FOREIGN...

  • Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the p...

    Please help me on the SQL queries, thank you so much. Write a query to display the title and publisher as well as the publisher contact for each book using JOIN...USING clause. Write a query to show the first and last names of customers who have ordered cooking books. Use the WHERE clause to join the tables. Write a query to show the title, cost and ISBN of each book in the books table. If the book has been ordered,...

  • drop table department cascade constraints; create table department ( Dname   varchar2(15)   not null, Dnumber int   not...

    drop table department cascade constraints; create table department ( Dname   varchar2(15)   not null, Dnumber int   not null, Mgr_ssn   char(9)   not null, mgr_start_date   Date, primary key (Dnumber), Unique    (Dname)); insert into DEPARTMENT values ('Research', '5', '333445555', '22-May-1988'); insert into DEPARTMENT values ('Administration', '4', '987654321', '01-Jan-1995'); insert into DEPARTMENT values ('Headquarters', '1', '888665555', '19-Jun-1981'); drop table employee cascade constraints; create table employee ( Fname   varchar2(15) not null, Minit   char(1), Lname   varchar2(15) not null, Ssn   char(9), Bdate   date, Address   varchar2(30), Sex   char(1),...

  • Oracle 12c SQL Chapter 12 Determine which orders were shipped to the same state as order...

    Oracle 12c SQL Chapter 12 Determine which orders were shipped to the same state as order 1014. CREATE TABLE Orders (Order# NUMBER(4), Customer# NUMBER(4), OrderDate DATE NOT NULL, ShipDate DATE, ShipStreet VARCHAR2(18), ShipCity VARCHAR2(15), ShipState VARCHAR2(2), ShipZip VARCHAR2(5), ShipCost NUMBER(4,2), CONSTRAINT orders_order#_pk PRIMARY KEY(order#), CONSTRAINT orders_customer#_fk FOREIGN KEY (customer#) REFERENCES customers(customer#)); INSERT INTO ORDERS VALUES (1000,1005,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('02-APR-09','DD-MON-YY'),'1201 ORANGE AVE', 'SEATTLE', 'WA', '98114' , 2.00); INSERT INTO ORDERS VALUES (1001,1010,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('01-APR-09','DD-MON-YY'), '114 EAST SAVANNAH', 'ATLANTA', 'GA', '30314', 3.00); INSERT INTO ORDERS VALUES (1002,1011,TO_DATE('31-MAR-09','DD-MON-YY'),TO_DATE('01-APR-09','DD-MON-YY'),'58...

  • Here is the P4 university database ---Drop tables --Drop Table FACULTY Cascade Constraints; --Drop Table OFFERING...

    Here is the P4 university database ---Drop tables --Drop Table FACULTY Cascade Constraints; --Drop Table OFFERING Cascade Constraints; --Drop Table STUDENT Cascade Constraints; --Drop Table COURSE Cascade Constraints; --Drop Table ENROLLMENT Cascade Constraints; Create Table STUDENT( Std_ID NUMBER(3) Constraint Student_STD_ID_FK PRIMARY KEY, Std_FN Varchar2 (9), Std_LN Varchar2 (8) , Std_City Varchar2 (10), Std_State Varchar2 (4), Std_Zip Number (5), Std_Major Varchar2 (6), Std_Class Varchar2 (3), Std_GPA NUMBER (3,2)); ---Insert records into Student Insert Into STUDENT Values( 101, 'Joe', 'Smith','Eau Clare','WI',18121,'IS','FR',3.8); Insert...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT