5. Write a query that displays the longest stay of any guest at the hotel chain.
ID: 3888148 • Letter: 5
Question
5. Write a query that displays the longest stay of any guest at the hotel chain. The length of a guests stay is the end date of the stay minus the start date of the stay plus one. Again you'll need to use an aggregate function on a single table. Your query should produce a table with the following columns and headers: Duration of Longest Stay (in days) 6. Write a query that displays how many guests have stayed in hotels in each of the states. Count multiple stays by a single guest only once. This query will require an aggregate function and a join of tables. Your query should produce a table with the following columns and headers: State Number of guests staying in hotel in this state 7. Write a query that displays how many different hotels that the guest with full name Erasmo Randall has stayed at. If Erasmo Randall has stayed at a hotel more than once, count the hotel only once. This query will require an aggregate function with a join. Your query should produce a table with the following columns and headers: Number of guests stayinh hotels in this state 8. Write a query that displays the following information about the hotel with the most expensive room rate: The name of the hotel, the room number of the room, the type of the room and the room rate. This query will require a join and a nested where query. Your query should produce a table with the following columns and headers: l Name n Number of room rate 9. Write a query which displays the list of rooms (room number) at the Bar Harbor Hotel which are available during the period Sept 9, 2017 through Sept 25, 2017. To write this query, note that a room is available during this period if, for all of the room's bookings( sdi,,edi), either sdi> 09/25/2017 or ediExplanation / Answer
//sorry questions with so many parts are not permitted to solve fully.
solution5:
select datediff(day,startdate,enddate) AS stays from Booking;
SELECT MAX(stays)
FROM Booking;
solution6:
select COUNT (DISTINCT GID)AS Number_of_guests_satying_in_this_hotel,state
from booking
where GID IN (select * from hotel,booking
where hotel.HID=booking.HID) group by states
Related Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.