Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

6. Write a query that displays how many guests have stayed in hotels in each of

ID: 3888750 • Letter: 6

Question

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: State Number of guests stayinh hotels in this state 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: Hotel Name Room Number Type of room room rate

Explanation / Answer

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