SQL Server 2008: Getting duration between user sessions
- by Nai
I have this table
UserID SessionID SessionStart SessionEnd
-----------------------------------------------
1 abc1 2010-1-1 2010-1-2
5 def3 2010-1-5 2010-1-9
1 llk0 2010-1-10 2010-1-11
5 spo8 2010-1-13 2010-1-15
1 pie7 2010-1-16 2010-1-29
I would like to be able to find the days between the end of one session to the start of the next session for each particular user.
So I am looking to get something like
UserID DaysBetweenSessions
-----------------------------
1 8
1 5
5 4
Thanks!