Hi
This problem cannot be solved with one single sql select statement. You need some procedural code, e.g. programmed in PSM, C, Java or PHP. I would design a user defined function or stored procedure in PSM to carry out this task. The procedure may function that way:
Given a guest's request for booking consecutive dates starting with startdate up to enddate, the procedure tentatively allocates rooms. If booking period cannot be covered by only one room, UDF tentatively books alternative rooms. The result will be shown to guest/user. If he decide to book the suggested rooms changes to booking table will be committed, if not, then rollbacked.
Inside the procedure this query may be used to get an overview on the booking situation:
select caldate, roomID, bookingid from booking
where rstatus = 1 and caldate between '2010-08-01' and '2010-08-05'
group by caldate, roomID, bookingid order by caldate, roomID;
-- where '2010-08-01' and '2010-08-05' are examples for startdate and enddate which
-- should be replaced by variables depending on your programming environment. Attention: This code not tested
-- tesu