I am currently in a bit of a pickle trying to sort out some queries from one of our databases. The table that is giving me issues looks pretty much as follows:
id | bookingStartDate | bookingEndDate | bookingLength | customerID | roomNumber
-----------------------------------------------------------------------------------
310 | 2016-11-10 | 2016-11-17 | 7 | 004943 | 583
443 | 2017-01-15 | 2016-11-29 | 14 | 008745 | 345
What I am trying to achieve is to provide a good idea of the availability of specific rooms over a specific window of time. The way the data is currently stored, I do have access to both the start and the end of the booking as well as the amount of nights the booking will last for.
What I am trying to do is create a query to check the availability of a specific room given a range of dates, such as from then 10th of November to the 20th of November 2016.
In order to solve it I have tried left joining a calendar table with this one and filtering on the room number. The join however is relying on the bookingStartDate or the end one and I am not sure on how to proceed to instead get the data to show the days in between the two when the room is also occupied.
Any help or suggestion would be awfully appriciated!