SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with hotel exercise

    Hotel (hotelNo,hotelName,hotelAddress)
    Room (hotelNo,roomNo,type,price)
    Guest (guestNo,guestName,guestAddress)
    Booking (hotelNo,guestNo,dateFrom,dateTo,roomNo)

    Use subqueries instead of JOIN (inner or outer)


    What is the percentage of lost income from unoccupied rooms at each hotel on
    July 6 2008? Round to the nearest % using the ROUND function, and use || to
    concatenate % to your output

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    where's your attempt to solve this?

    we don't do homework assignments here

    however, we will help you to do them

    so, let's see your attempt
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well we could become a homework club couldn't we?

  4. #4
    SitePoint Member
    Join Date
    Nov 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry about that. I was able to get the loss income for each room but dont know how to turn it into percentage.

    SELECT hotelno, SUM(price) FROM room r
    WHERE roomno NOT IN
    (SELECT roomno FROM booking b, hotel h
    WHERE (datefrom <= DATE'2008-07-06' AND
    dateto >= DATE'2008-07-06') AND
    b.hotelno = h.hotelno)
    GROUP BY hotelno;

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by jamraz View Post
    I was able to get the loss income for each room ...
    may i ask which database system you ran this on?

    sure doesn't look like mysql
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •