views:

164

answers:

4

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_DATE AND
dateTo >= CURRENT_DATE) AND
b.hotelNo = h.hotelNo AND hotelName = 'Paris Hilton');
+5  A: 

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?

cpalmer
thanks so much cpalmer..... and do you by any chance know how to evaluate this query by the DBMS?
Kevinniceguy
@Kevinniceguy: If this answer helped you, mark it as the accepted answer by clicking on the checkmark.
musicfreak
Kevvinniveguy, "DBMS" means "DataBase Management System" which is a generic term to discuss any database. Which DBMS are you using specifically? MySQL, Microsoft SQL, Oracle? It will be a different process depending on which you're using.
David Souther
If you are having trouble comprehending this statement, perhaps you need to go and read up on the basics of how relational databases work. Specifically, in this order, history of databases, Entity Relational Diagrams, normalization, SQL features/drawbacks/uses/history, creating tables, doing simple selects, then joins, then summary queries, and, finally, sub-queries. There's a lot of thought that has went into that statement and to fully comprehend it in a 550~ character comment is hard to do.
Nitrodist
thanks...it says to get some points for voting
Kevinniceguy
A: 

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.

Jeeva S
+1  A: 

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.

Niten
A: 

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?

Thomas