I am trying to calculate the time difference between events (in seconds) on a kiosk machine. Each time a person begins using the screen it creates a VisitID. Within that visit, a series of computer events are created that determine the beginning of the screen and the ending of the screen I have identified each event for each screen. Depending on what choices the user makes, they may or may not go through each event or screen. My data looks like this:
VisitID ScreenTime EventName
1 13:24:08 WelcomeScreen_Begin
1 13:24:15 Welcome_End
1 13:24:15 NameScreenInit_Start
1 13:24:32 Name_Screen_Terminate
1 13:24:33 CompanyScreen_Enter
1 13:24:45 Company_Lookup
1 13:24:45 Signoff_Now
1 13:24:52 SignOutEnd
2 13:45:02 WelcomeScreen_Begin
2 13:45:15 Welcome_End
2 13:45:15 NameScreenInit_Start
2 13:45:40 Name_Screen_Terminate
2 13:45:40 Signoff_Now
2 13:45:58 SignOutEnd
I would like for my results to look like this:
VisitID WelcomeScreen NameScreen CompanyScreen SignoffScreen
1 00:00:7 00:00:17 00:00:12 00:00:07
2 00:00:13 00:00:25 NULL 00:00:18
Ultimately, I would like to calculate the average time spent on EACH screen:
WelcomeScreenAVG NameScreenAVG CompanyScreenAVG SignoffScreenAVG
00:00:10 00:00:21 00:00:12 00:00:13
I have been able to use subscripts to grab each timestamp within a DATEDIFF clause, but it ONLY works if I include the VisitID in the WHERE clause. I have hundreds of thousands of entries so that isn't the way to do it. I've been racking my brain on this for days. Does anyone have a solution, or at least know what I should be looking to do instead? Thanks in advance!
There are a few occurrences when the only event available to signify the beginning of one screen is the same event that ends the prior screen. For Example:
VisitID ScreenTime EventName
34 08:34:36 Delivery_summaryConfirm
34 08:34:47 Seal_questionsBegin
34 08:35:17 EndSeal_Inquiry
^^This is 2 Screens^^ In the example above, While Seal_questionsBegin is the Beginning of the SealInquiry Screen, it is the only event able to signify the end of the DeliverySummary Screen. This is because the DeliverySummary Screen is always followed by a SealInquiry Screen.