The Scenarion is DEMO001 system is booked from 10-Aug to 11-Aug by some user.
START_DATE END DATE SYSTEM
2016-08-10 2016-08-11 DEMO001
Based on your requirements, you want to disallow a booking if either the start or end date falls in between a given record. You can just use a
CASE expression for this. I have hardcoded
2016-08-15 as the start and end dates which you are using.
SELECT SYSTEM, CASE WHEN (START_DATE >= '2016-08-08' AND START_DATE <= '2016-08-15') OR (END_DATE >= '2016-08-08' AND END_DATE <= '2016-08-15') THEN 0 ELSE 1 END AS allowBooking FROM yourTable