Guest House Assessment Sample Queries

From SQLZOO
Revision as of 20:41, 26 July 2016 by Andr3w (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Show who made the booking for room 101 on 17th Nov 2016

SELECT first_name,last_name
FROM booking JOIN guest ON guest_id = guest.id
 WHERE room_no=101 AND booking_date='2016-11-17'

Show the date of check in and check out and number of nights for booking 5046

SELECT booking_date AS 'check in',
              DATE_ADD(booking_date,INTERVAL nights DAY) AS 'check out',
              nights
FROM booking
 WHERE booking_id=5046