Database Answers Header

Typical Queries for a Hotel Reservation System

Chateau Laurier,Ottawa,Canada

  • Home
  • Ask a Question
  • Data Models
  • FAQs
  • SQL Scripts
  • StateOfTheArt
  • Search
  • Site Map

    Underwater in Fiji
  • Here are two typical Queries ...
    
    Question 1 : What is the total revenue per reservation from all double rooms?
    
    Answer 1 :
       SELECT booking_ID,SUM(room_Price*Days_in (date_To - Date_From))
       FROM   Bookings, Rooms
       WHERE  room_Type_Code LIKE 'Double%'
       AND    Bookings.room_number = Rooms.room_number
       GROUP  BY booking_ID ;
    
    Question 2 :
    How many distinct guests have made bookings for Aug. 1997 in each hotel?
    
    Answer 2 :
        SELECT hotel_ID,hotel_Name,COUNT(DISTINCT guest_Number)
        FROM   Bookings
              ,Hotels
              ,Rooms
        WHERE ("Aug/97/" >= Month(date_From)
        OR     "Aug/97/" <= Month(date_To)  )
        AND    Bookings.room_number = Rooms.room_number
        AND    Rooms.hotel_ID       = Hotels.hotel_ID
        GROUP  BY hotel_ID, hotel_Name;
    

    [ Home Page | Ask Us a Question | Day in the Life | Email Us | FAQs | Search & Site Map ]

    © IceBreaker WebDesigns 2001