Skip to content

Instantly share code, notes, and snippets.

@oisdk
Last active December 13, 2015 19:38
Show Gist options
  • Save oisdk/f94ca76e9c6eeb3e73c3 to your computer and use it in GitHub Desktop.
Save oisdk/f94ca76e9c6eeb3e73c3 to your computer and use it in GitHub Desktop.
SELECT hotel_name
FROM hotels
WHERE
city = 'Waterford' AND
hotel_num IN (
SELECT r.hotel_num
FROM rooms AS r
WHERE r.room_num NOT IN (
SELECT b.room_num
FROM bookings AS b
WHERE
b.hotel_num = r.hotel_num AND
'2016-10-05' BETWEEN b.arr_date AND b.dep_date
)
GROUP BY hotel_num
HAVING COUNT(*) >= 5
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment