Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT [RespondentId], [StartDateTime], [EndDateTime]
- INTO [tmp].[RESULT]
- FROM (
- SELECT [RespondentId], [StartDateTime], [EndDateTime]
- FROM
- (
- SELECT [RespondentId],
- [EndDateTime] AS [StartDateTime],
- LEAD(StartDateTime) OVER (PARTITION BY [RespondentId] ORDER BY [StartDateTime]) AS [EndDateTime]
- FROM @INPUT
- ) A
- WHERE [A].[EndDateTime] IS NOT NULL
- ) AS B
- WHERE ABS(DATEDIFF(mi, [EndDateTime], [StartDateTime])) <= @GapSize
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement