First Wish you a Happy New Year 
Sorry about the first one. Actually I was just checking "not in" operator.
Thanks for correcting the next two.
I've tried, these give correct results.
(4)List the names of hotels which are located in more than two cities
Code:
SELECT hname,COUNT(city) AS 'No. Of Cities'
FROM Hotel
GROUP BY hname
HAVING COUNT(city) > 2;
(5)For a given hotel(hno supplied) list total no. of room of different type.
Code:
SELECT type, COUNT(type) AS 'No. of Rooms'
FROM Room
WHERE hno = 13
Group BY type
(6)For a given hotel(hname supplied) list total no. of room of different type.
Code:
SELECT type, COUNT(type) AS 'No. of Rooms'
FROM Room R INNER JOIN Hotel H ON R.hno=H.hno
WHERE hname = 'The Amber'
Group BY type
(7)List names of hotels which have minimum charge for Luxury room for a given city.
Code:
SELECT hname,min(charge) AS 'Min. Charge'
FROM Room R INNER JOIN Hotel H ON R.hno=H.hno
WHERE city = 'Kolkata' AND type = 'Luxury'
GROUP BY hname
(8)List names of all hotels where charge of Luxury room is between 3000 and 4000
Code:
SELECT hname
FROM Room R INNER JOIN Hotel H ON R.hno=H.hno
WHERE charge BETWEEN(3000) AND(4000) AND type = 'Luxury'
GROUP BY hname
(9)Count the number of bookings of Luxury room in a given hotel in 2012.
(10)Find out total earnings of a hotel in 2012.
Code:
SELECT SUM(charge) AS 'Total Earnings'
FROM Room R INNER JOIN Booking B ON R.hno=B.hno JOIN Hotel H ON R.hno=H.hno
WHERE H.hname = 'Hayatt Hotel'
AND B.idate BETWEEN('2012-01-01') AND('2012-12-31')
This gives NULL results
(11)Find guest name that has booking on Luxury Room in 2013.
Do I have to link 3 tables in (9) & (11)
Please tell how do I find the last three.
Bookmarks