Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Complex Query Help
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00611652
Message ID:
00611709
Views:
25
This is off the top of my head. I think that you'll have to play with the offsets a little. It also won't find any time after the last meeting of a room and it doesn't limit the search to a specific range. I'll leave that up to you.

BTW, changing the INNER JOIN to a LEFT OUTER JOIN might catch correct the problem of not finding the last period of a room.

SELECT
DATEADD(minute, 1, m1.endTime) AS beginTime,
DATEADD(minute, @gap+1, m1.endTime) AS endTime
FROM
meeting m1
INNER JOIN meeting m2 ON m2.beginTime > m1.endTime AND m1.roomID = m2.roomID
WHERE
DATEDIFF(minute, m1.endTime, m2.beginTime) >= @gap+1

-Mike
Michael Levy
MCSD, MCDBA
ma_levy@hotmail.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform