Hi ,
I 'm new to DataBase, is there any one who can help me to this kind of questions answer.
Thanks
Ashi,
1. The following tables form part of a database held in a relational DBMS:
Hotel (Hotel_No, Name, Address)
Room (Room_No, Hotel_No, Type, Price)
Booking (Hotel_No, Guest_No, Date_From, Date_To, Room_No)
Guest (Guest_No, Name, Address)
where Hotel contains hotel details and Hotel_No is the primary key Room contains room details for each hotel and (Hotel_No, Room_No) forms the primary key.
Booking contains details of the bookings and the primary key comprises (Hotel_No, Guest_No, Date From) and Guest contains guest details and Guest_No is the primary key.
Write the SQL statements for the following
1. What is the total daily revenue from
all the double rooms?
2. How many different guests have made bookings for August, 2006?
3. List the price and type of all rooms at the hotel Land Mark.
4. What is the total income from bookings for the hotel Manor today?
Hemant SrivastavaPosted Oct 24, 2013, 4:20 PM
If you problem is resolved, could you accept the answer.
Ashi MPosted Oct 24, 2013, 11:22 AM
Hemant SrivastavaPosted Oct 21, 2013, 1:44 PM
Query for the "What is the total daily revenue from all the double rooms"
SELECT SUM(Price)
FROM Hotel
INNER JOIN Room ON Room.Hotel_No = Hotel.Hotel_No
INNER JOIN Booking ON Booking.Hotel_No = Hotel.Hotel_No AND Booking.Room_No = Room.Room_No
WHERE Room.Type = 'Double'
Hemant SrivastavaPosted Oct 21, 2013, 11:54 AM
SELECT SUM(Price)
FROM Hotel
INNER JOIN Room ON Room.Hotel_No = Hotel.Hotel_No
INNER JOIN Booking ON Booking.Hotel_No = Hotel.Hotel_No AND Booking.Room_No = Room.Room_No
WHERE Hotel.Name = 'Manor' AND (DATEDIFF(DAY, GETDATE(), Date_From) = 0)
Hemant SrivastavaPosted Oct 21, 2013, 11:40 AM
Query for the "List the price and type of all rooms at the hotel Land Mark."
SELECT Price, Type FROM Hotel
INNER JOIN Room ON Room.Hotel_No = Hotel.Hotel_No
WHERE Hotel.Name = 'Land Mark'
Hemant SrivastavaPosted Oct 21, 2013, 11:39 AM
Query for the "How many different guests have made bookings for August, 2006?"
SELECT COUNT(Booking.Guest_No) FROM Booking
INNER JOIN Guest ON Guest.Guest_No = Booking.Guest_No
WHERE Date_From BETWEEN 'Aug 1 2006' AND 'Aug 31 2006'