I’ve got a table with two columns Time and Login, showing when a user has sent calls during a day.
On a per user basis, I need to find the greatest, smallest and average session length where the session length is calculated as the time in minutes between the first call and the last call on any given day.
Table:
Time Login
2012-05-29 20:01:26 A
2012-05-29 20:01:40 A
2012-05-29 20:02:27 A
2012-05-29 20:58:46 A
2012-05-29 20:59:50 A
2012-05-29 21:00:12 A
2012-05-29 21:00:36 A
2012-05-30 21:28:28 A
2012-05-30 21:29:08 A
2012-05-30 21:29:13 A
2012-05-30 21:29:25 A
2012-04-06 10:25:24 A
2012-04-06 10:25:53 A
2012-04-06 10:26:35 A
2012-04-27 12:05:45 A
2012-04-27 12:06:06 A
Desired output would look something like this:
MaxSession Login
59 A
As mentioned above the same output is required for MinSession and AverageSession.
I am completely stuck for hours and have really no clue how to get this done.
What I’ve achieved is to get the unique active days per Login.
I just cannot figure out how to achieve the next steps, though, which would be:
- get the first entry per Login per day
- get the last entry per Login per day
- calculate the difference in minutes between last entry
and first entry per day per Login as SessionLength - select the Max, Min, and Average SessionLenght per Logins
I would be very grateful for any type of help!
Try this
Grouped by day
Please enclose columns in ‘ ‘ for the columns like ‘time’
Max,Min and average sessions
Presently ignoring the seconds while calculating the minutes.