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.
1. For all hotels in city Paris in France, list hotel name, hotelAddress, room type and price of all Single, Double or Family rooms with a price below 100.00 per night, in descending order of hotelName, ascending order of price and descending order of type. List each result entry only once.
2. For hotels in city Surrey in Canada, list the bookings for which no dateTo has been specified. List the hotelName, hotelAddress, room number, dateFrom and dateTo. [Note: Hotels in South Surrey and North Surrey should be excluded explicitly. Do not rely on specific sample data instances.]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
