Advertisement
Guest User

Untitled

a guest
Feb 26th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. DECLARE @sessionsCount int = 1;
  2. DECLARE @timeLimitBetweenSessions int = 5;
  3.  
  4. SELECT
  5. --ttt.id, rownum23, trt, ttt.CreateDateTime, DATEDIFF(minute, pl2.CreateDateTime, pl1.CreateDateTime)
  6. a.Id, a.User_Id,
  7. b.User_Id,
  8. a.CreateDateTime StartActivity,
  9. b.CreateDateTime EndActivity,
  10. a.RowNum1,
  11. b.RowNum2,
  12. @sessionsCount as 'SessionNumber'
  13. FROM (
  14. select Id,
  15. User_Id ,
  16. CreateDateTime
  17. ,ROW_NUMBER() OVER (ORDER BY [User_Id]) AS RowNum1
  18. from [dbo].[PageLoadings]) as a
  19. JOIN (
  20. SELECT [Id]
  21. ,[User_Id]
  22. ,[CreateDateTime]
  23. ,ROW_NUMBER() OVER (ORDER BY [User_Id]) AS RowNum2
  24. FROM [dbo].[PageLoadings]) as b
  25.  
  26. on a.RowNum1 = (b.RowNum2 - 1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement