Say I got a meeting room named niagara. I want to find who occupied this room given a start and end time range. The table name is "niagara". Lets just keep the search for today.
Person InTime OutTime
A 9AM 1PM
B 10AM 12PM
C 10:25AM 1:30PM
D 9AM 9:00 PM
E 12:20PM 5PM
F 10:45 AM 11:30 PM
Give the list of persons who occupied between 10:30 AM and 12:15 PM
Expected Answer is - A,BC,D and F
How to do this
I tried
SELECT PERSON
FROM NIAGARA
WHERE (IN_TIME > START_TIME AND OUT_TIME < END_TIME)
OR (IN_TIME < START_TIME AND OUT_TIME > END_TIME)
BTW I was asked this in a job interview.
So which means this is the way I am trying to learn the answer