this query gets me all the overlap booking dates
select BookingId,convert(varchar(10),b1.Start,120) Stdate,convert(varchar(5),b1.Start,108) StTime,convert(varchar(5),b1.Finish,108) edtime
from Bookings b1
where exists (
select BookingId from Bookings b2
where b1.Bookingid <> b2.Bookingid and b1.start <= b2.finish and b1.finish >= b2.start AND b2.ResourceID = b1.ResourceID
)
and b1.start >=@Startdate and b1.Finish <= @Enddate
here is the data it is returning
BookingId stdate sttime edtime
1 2004-10-08 8.00 17.30
2 2004-10-08 9.00 14.30
3 2004-10-08 10.00 16.00
4 2004-10-08 11.00 12.30
5 2004-10-08 18.00 18.30
6 2004-10-08 18.00 18.30
what i wanted is some how i should be able to group these
overlapped bookings
Id's 1,2,3 and 4 are belongs to one group as they all overlap together and Id's 5 and 6 belong to another group
like wise we need to identify..
this is basically to have different background for each group at my front end
any suggesions..
Thanks
select BookingId,convert(varchar(10),b1.Start,120) Stdate,convert(varchar(5),b1.Start,108) StTime,convert(varchar(5),b1.Finish,108) edtime
from Bookings b1
where exists (
select BookingId from Bookings b2
where b1.Bookingid <> b2.Bookingid and b1.start <= b2.finish and b1.finish >= b2.start AND b2.ResourceID = b1.ResourceID
)
and b1.start >=@Startdate and b1.Finish <= @Enddate
here is the data it is returning
BookingId stdate sttime edtime
1 2004-10-08 8.00 17.30
2 2004-10-08 9.00 14.30
3 2004-10-08 10.00 16.00
4 2004-10-08 11.00 12.30
5 2004-10-08 18.00 18.30
6 2004-10-08 18.00 18.30
what i wanted is some how i should be able to group these
overlapped bookings
Id's 1,2,3 and 4 are belongs to one group as they all overlap together and Id's 5 and 6 belong to another group
like wise we need to identify..
this is basically to have different background for each group at my front end
any suggesions..
Thanks