Practice Interview Questions
| Question | Status |
|---|---|
Create a query to find out how many times each room has been booked and calculate the total revenue generated from those reservations, considering the number of nights booked. Display the results with the room having the highest bookings at the top, followed by descending order based on the booking frequency.
rooms table:
| Column Name | Description |
|---|---|
| room_id | Identifier of each room |
| name | Name assigned to each room |
| description | Short description of the room |
| price | Price of the room per night |
rentalHistory table:
| Column Name |
|---|
| Description |
|---|
| rental_id | Identifier of each reservation |
| room_id | Identifier of the room reserved |
| number_nights | Number of nights the room was reserved |
Example Output:
| name | description | number_of_bookings | total_earnings |
|---|---|---|---|
| Executive Suite | Luxurious suite with modern amenities. | 15 | 3750.00 |
| Zen Escape | Tranquil room with calming ambiance. | 5 | 750 |
Create a query to find out how many times each room has been booked and calculate the total revenue generated from those reservations, considering the number of nights booked. Display the results with the room having the highest bookings at the top, followed by descending order based on the booking frequency.
rooms table:
| Column Name | Description |
|---|---|
| room_id | Identifier of each room |
| name | Name assigned to each room |
| description | Short description of the room |
| price | Price of the room per night |
rentalHistory table:
| Column Name | Description |
|---|---|
| rental_id | Identifier of each reservation |
| room_id | Identifier of the room reserved |
| number_nights | Number of nights the room was reserved |
Example Output:
| name | description | number_of_bookings | total_earnings |
|---|---|---|---|
| Executive Suite | Luxurious suite with modern amenities. | 15 | 3750.00 |
| Zen Escape | Tranquil room with calming ambiance. | 5 | 750 |