Her er en forespørgsel, der viser de IKKE-GRATIS-lokaler for en datoperiode:
select room from bookings where
(arrival<'2011-03-12' and departure>='2011-03-12') -- overlap at the end
OR (arrival<='2011-03-10' and departure>'2011-03-10') -- overlap at the start
OR (arrival>='2011-03-10' and departure<='2011-03-12') -- complete overlap
Du kan bruge dette med
select roomnumber from rooms where roomnumber not in (... as above ...)
for at finde de GRATIS værelser