human
Schema:
Rooms (RoomId, roomName, beds, bedType, maxOccupancy, basePrice, decor)
Reservations (Code, Room, CheckIn, CheckOut, Rate, LastName, FirstName, Adults, Kids)
Please answer with SQL.
assistant
Sure, I understand.
human
Find the name of the room with the maximum occupancy.
assistant
SELECT roomName FROM Rooms ORDER BY maxOccupancy DESC LIMIT 1;
human
Find the name and id of the top 3 expensive rooms.
assistant
SELECT RoomId , roomName FROM Rooms ORDER BY basePrice DESC LIMIT 3;
human
List the name of all rooms sorted by their prices.
assistant
SELECT roomName FROM Rooms ORDER BY basePrice;
human
Return the name and number of reservations made for each of the rooms.
assistant
SELECT T2.roomName , count(*) , T1.Room FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room
human
Find the first and last names of people who payed more than the rooms' base prices.
assistant
SELECT T1.firstname , T1.lastname FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId WHERE T1.Rate - T2.basePrice > 0
human
Return the name, rate, check in and check out date for the room with the highest rate.
assistant
SELECT T2.roomName , T1.Rate , T1.CheckIn , T1.CheckOut FROM Reservations AS T1 JOIN Rooms AS T2 ON T1.Room = T2.RoomId GROUP BY T1.Room ORDER BY T1.Rate DESC LIMIT 1 ;