The Student Room Group

HND Computing - SQL Help

Hi,

Currently working on some SQL Work for college and having a bit of trouble getting my head around all the work.

Excuse my poor formatting here.

Hotel Name --------- Guest Id ------------------------ Arrival ------------------Depart
Seaview Hotel --------- 1 ---------21/4/09 --------------- 24/4/09
Wilson's Hotel ---------- 11 --------- 8/5/09 ------------------ 10/5/09
Seaview Hotel ---------- 2 ------------ 22/4/09 ------------25/4/09
Mountain Lodge --------3 ------------23/4/09 ------------24/4/09
Mountain Lodge --------11 ------------26/4/09 ------------ 29/4/09
Seaview Hotel ---------- 9 ------------ 28/4/09 ------------1/5/09
Mountain Lodge ---------5 ------------ 2/5/09 ------------ 3/5/09
Mountain Lodge ---------3 ------------ 4/5/09 ------------ 6/5/09
Wilson's Hotel -------- 11 ------------4/5/09 ------------ 7/5/09
Seaview Hotel --------------- 4 ------------6/5/09 ------------ 7/5/09


This is just one table in the database and from this i need to find :


4. How many customers have stayed in each of the hotels in the group? You should give the number of customers and the name and postal information of each hotel.


-- The last part is irrelevant because I can get that easily enough



5. What is the average number of nights stayed in one visit to any of the hotels in the group?

I'm not great at SQL have used the AVG function a bit but I've no idea how to find the Average of the difference between 2 dates.


Theirs other questions too but If could get help with those that'd be great,

Cheers.
(edited 12 years ago)
Reply 1
this should it for you:

SELECT HotelName, Count(GuestID) AS GuestsInEachHotel
FROM Hotel
GROUP BY HotelName
Reply 2
Hi Cheers for the reply Theol, did a quick google search and managed to pick up what i needed, pretty much same as what your suggesting.

Cheers.

Quick Reply

Latest

Trending

Trending