Explain this SQL query in plain English [closed]
Please explain, in plain English, what question this SQL query answers:
SELECT SUM(price) FROM Room r, Hotel h
WHERE r.hotelNo = h.hotelNo and hotelName = 'Paris Hilton' and
roomNo NOT IN
(SELECT roomNo FROM Booking b, Hotel h
WHERE (dateFrom <= CURRENT_DAT开发者_StackOverflow社区E AND
dateTo >= CURRENT_DATE) AND
b.hotelNo = h.hotelNo AND hotelName = 'Paris Hilton');
I'm assuming you're asking what does that query do in plain English:
How much would it cost to book all rooms at the "Paris Hilton" hotel that are vacant today?
This query appears to return the sum of the prices of all the rooms in the Paris Hilton hotel which aren't booked for today.
question would be like,
find out list of room that are not booked so far till today in the hotel "Paris Hilton" and return the sum of that amount.
This is probably supposed to represent the total price of rooms available as of today at the "Paris Hilton" hotel. Why they are filtering on both HotelNo and HotelName.
I guess the question would be:
What is the total value of rooms available as of today at the "Paris Hilton" hotel?
精彩评论