Explain this SQL query in plain English

Please explain, in plain English, what question this SQL query will answer:

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_DATE AND dateTo >= CURRENT_DATE) AND b.hotelNo = h.hotelNo AND hotelName = 'Paris Hilton'); 
+4
source share
4 answers

I assume that you are asking what this query does in plain English:

How much does it cost to book all the rooms at the Paris Hilton Hotel that are vacant today?

+6
source

This request returns the price of all rooms at the Paris Hilton Hotel that are not currently booked.

+1
source

the question will be

find out the list of rooms that have not been booked until today at the Paris Hilton Hotel and return the amount.

0
source

This will probably represent the total cost of the rooms available today at the Paris Hilton Hotel. Why do they filter both HotelNo and HotelName.

I think the question will be as follows:

What is the total room price available at the Paris Hilton today?

0
source

Source: https://habr.com/ru/post/1306594/


All Articles