Question
Can someone help me with these questions? I am using SQL plus. This is database relations shema. Hotel (hotelNo, hotelName, hotelAddress, country) Room (roomNo, hotelNo,
Can someone help me with these questions?
I am using SQL plus.
This is database relations shema.
Hotel (hotelNo, hotelName, hotelAddress, country)
Room (roomNo, hotelNo, type, price)
Guest (guestNo, guestName, guestAddress, country)
Booking (hotelNo, guestNo, dateFrom, dateTo, roomNo)
I created tables.
CREATE TABLE Hotel (hotelNo NUMBER(4) NOT NULL ,hotelName VARCHAR2(16) NOT NULL ,hotelAddress VARCHAR2(40) NOT NULL ,country VARCHAR2(20) NOT NULL ,PRIMARY KEY (hotelNo) );
CREATE TABLE Room (hotelNo NUMBER(4) NOT NULL ,roomNo NUMBER(4) NOT NULL ,type VARCHAR2(8) NOT NULL ,price NUMBER(6,2) NOT NULL ,PRIMARY KEY (hotelNo, roomNo) );
CREATE TABLE Guest (guestNo NUMBER(4) NOT NULL ,guestName VARCHAR2(15) NOT NULL ,guestAddress VARCHAR2(40) NOT NULL ,country VARCHAR2(20) NOT NULL ,PRIMARY KEY (guestNo) );
CREATE TABLE Booking (hotelNo NUMBER(4) NOT NULL ,guestNo NUMBER(4) NOT NULL ,dateFrom DATE NOT NULL ,dateTo DATE ,roomNo NUMBER(4) NOT NULL ,PRIMARY KEY (hotelNo, guestNo, dateFrom) );
-Use only a single query statement to solve each query question.
-Do NOT use subqueries for this
By the way, you don't have to calculate anything for these questions since you don't have data.
I couldn't able to post data because it was too long.
Please just provide me codes about how to do it.
For example question number1, you can just write code like this.
SELECT hotelName, hotelAddress, type, price FROM Hotel, Room WHERE country = 'France' AND hotelAddress = '%Paris' type IN ('Single', 'Double', 'Family') AND price < 100.00 ORDER BY hotelName ASC;
Although this code is wrong and I would like to know why I am getting an error.
Here is the questions.
8. What is the total income for each room type from bookings for each hotel (listing hotel names, not just hotelNo) today? Use 2021-01-25 as today's date. List in ascending order of hotel name and room type.
9. List the new hotels that are still under construction, i.e. no room data in the Room table as yet for these hotels.
10. What is the percentage of hotels still under construction? List the total number of hotels, number of hotels completed, the number of hotels under construction, and the percentage of hotels under construction. (Note: NO SUBQUERY; use OUTER JOIN with aggregates.)
Here is sample data.
-- Insert Sample Data
--
INSERT INTO Hotel
VALUES (1, 'Grosvenor Hotel', '100 Rue St. Dominique, Paris', 'France');
INSERT INTO Hotel
VALUES (2, 'Holiday Hotel', '789 Paris St.,Surrey', 'Canada');
INSERT INTO Hotel
VALUES (3, 'Holiday Inn', '56 Rue Bonaparte, Paris', 'France');
--
INSERT INTO Room
VALUES (1, 1, 'Single', 40);
INSERT INTO Room
VALUES (1, 2, 'Single', 40);
INSERT INTO Room
VALUES (1, 3, 'Single', 40);
INSERT INTO Room
VALUES (1, 4, 'Single', 40);
INSERT INTO Room
VALUES (1, 5, 'Double', 55);
INSERT INTO Room
VALUES (1, 6, 'Double', 55);
INSERT INTO Room
VALUES (1, 7, 'Double', 55);
INSERT INTO Room
VALUES (1, 8, 'Double', 55);
INSERT INTO Room
VALUES (1, 9, 'Family', 85);
INSERT INTO Room
VALUES (1, 10, 'Family', 90);
INSERT INTO Room
VALUES (1, 11, 'Deluxe', 110);
INSERT INTO Room
VALUES (1, 12, 'Deluxe', 120);
INSERT INTO Room
VALUES (1, 13, 'Deluxe', 120);
INSERT INTO Room
VALUES (2, 1, 'Double', 80);
INSERT INTO Room
VALUES (2, 2, 'Double', 80);
INSERT INTO Room
VALUES (2, 3, 'Double', 80);
INSERT INTO Room
VALUES (4, 16, 'Deluxe', 240);
INSERT INTO Room
VALUES (5, 1, 'Double', 80);
INSERT INTO Room
VALUES (5, 2, 'Double', 80);
INSERT INTO Room
VALUES (5, 3, 'Double', 80);
INSERT INTO Room
VALUES (5, 4, 'Double', 80);
INSERT INTO Room
VALUES (5, 5, 'Double', 80);
INSERT INTO Room
VALUES (5, 6, 'Double', 80);
INSERT INTO Room
VALUES (5, 7, 'Family', 120);
INSERT INTO Room
VALUES (5, 8, 'Family', 120);
INSERT INTO Room
VALUES (5, 9, 'Family', 120);
INSERT INTO Room
VALUES (5, 10, 'Family', 120);
INSERT INTO Room
VALUES (5, 11, 'Family', 120);
INSERT INTO Room
VALUES (5, 12, 'Family', 120);
INSERT INTO Room
VALUES (5, 13, 'Deluxe', 145);
INSERT INTO Room
VALUES (5, 14, 'Deluxe', 145);
--
INSERT INTO Guest
VALUES (1, 'Tony Saunders', '2000 Queens Avenue, Winnipeg', 'Canada');
INSERT INTO Guest
VALUES (2, 'Ed Cunningham', '30 Oak Street, Surrey', 'Canada');
INSERT INTO Guest
VALUES (3, 'Dawn Smith', '25 Walton Drive, Banff', 'Canada');
INSERT INTO Guest
VALUES (4, 'George Michaels', '30 Hampton Street, Paris', 'France');
INSERT INTO Guest
VALUES (5, 'Rick Hamilton', '987 King Edward Road, Paris', 'France');
INSERT INTO Guest
VALUES (6, 'Floyd Mann', '8 Wascana Crescent, Regina', 'Canada');
INSERT INTO Guest
VALUES (7, 'Thomas Lee', '200 Main Street,Surrey', 'Canada');
INSERT INTO Guest
VALUES (8, 'Sandy Alford', '234 Ontario Street, Montreal', 'Canada');
INSERT INTO Booking
VALUES (8, 1, DATE'2021-02-03', DATE'2021-03-26', 15);
INSERT INTO Booking
VALUES (8, 12, DATE'2021-02-01', DATE'2021-03-07', 20);
INSERT INTO Booking
VALUES (8, 5, DATE'2021-01-19', DATE'2021-02-28', 1);
--
COMMIT;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started