Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Complex Query Help
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00611652
Message ID:
00611772
Vues:
24
This message has been marked as the solution to the initial question of the thread.
Try this. You'll still miss a slot after the last record.
SELECT 
		DATEADD(minute, 1, m1.endTime) AS SlotBeginTime,
		DATEADD(minute, @gap, m1.endTime) AS SlotEndTime
	FROM meetings m1 
	JOIN meetings m2 ON m2.beginTime > m1.endTime AND m1.roomID = m2.roomID
	WHERE DATEDIFF(minute, m1.endTime, m2.beginTime) >= @gap+1
		 AND m2.BeginTime = ( SELECT MIN(m3.BeginTime) FROM meetings m3 
			WHERE m3.beginTime >= m1.endTime AND m3.roomID = m2.roomID )


>Michael
>
>That one returned me two identical records that overlapped an existing case.
>
>Current Data:
>
>RoomID      BeginTime                EndTime
>14          01/25/2002 07:30         01/25/2002 08:25
>14          01/25/2002 08:33         01/25/2002 10:28
>
>
>
>The result set returned:
>
>RoomID       BeginTime              EndTime
>14          01/25/2002 08:26        01/25/2002 09:26
>14          01/25/2002 08:26        01/25/2002 09:26
>
>
>
>Kirk
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform