Guest House Assessment Sample Queries

From SQLZoo
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
DataWars, Data Science Practice Projects - LogoDataWars: Practice Data Science/Analysis with +100 Real Life Projects