Created
June 5, 2014 09:17
-
-
Save nramsbottom/7aef73df60cc0945ea90 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| SET NOCOUNT ON | |
| DECLARE @Starts DATETIME | |
| DECLARE @Ends DATETIME | |
| SET @Starts = '2014-06-05 00:00:00' | |
| SET @Ends = '2014-06-05 23:59:00' | |
| select | |
| ROW_NUMBER() OVER (PARTITION BY DayId, ResourceId ORDER BY DayId, ResourceId) | |
| - ROW_NUMBER() OVER (PARTITION BY DayId, ResourceId, DATEPART(Hour, ActualStart) ORDER BY DayId, ResourceId, DATEPART(Hour, ActualStart)) AS groupId | |
| ,* | |
| from servicetime | |
| where | |
| (Actualstart >= @Starts AND ActualEnd <= @Ends) | |
| AND (Closed = 0 OR DenyBooking = 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment