I have an ACTIVITIES table where I am trying to calculate the time (in hours) between each OPERATION. The way it is set right now, I have CASE_KEY and for each CASE_KEY, there can be 1 to N operations. What I am trying to do is to calculate the time difference between each unique operation (for ex: for operation 0100 to 1000 the difference is 10 hours, for operation 1000 to 2000 the difference is 15 hours..etc) So I was able to utilize HOURS_BETWEEN and using SOURCE and TARGET, I was able to calculate the hours. What I have a column that indicates Operation start and Operation end. Based on that I am able to calculate the HOURS BETWEEN Operation by using End as SOURCE and Start as TARGET. The problem I run into is when there is an operation starting within an operation. So for ex: Operation 0100 starts, then right after Operation 1000 starts followed by Operation 1000 end and then after Operation 0100 end. Given how I am using Source and Target at the moment, it is definitely skewing the hours calculated for such cases. I have attached the image where I circled such case. How would I compute the HOURS_BETWEEN such operation accurately? It does NOT have to be using Source and Target but that's what I got it to work. Would appreciate any feedback.
Page 1 / 1
Here is one of the way(DATEDIFF) to calculate time between two "Short Act" in my case activity 'Extraction Start' and 'Extraction End'. Below logic calculates in minutes.
DATEDIFF (mi, PU_FIRST ( "replication_executions", "replication_execution_events"."timestamp", "replication_execution_events"."activity" = 'Extraction start', ORDER BY "replication_execution_events"."timestamp" ), PU_FIRST ( "replication_executions", "replication_execution_events"."timestamp", "replication_execution_events"."activity" = 'Extraction end', ORDER BY "replication_execution_events"."timestamp" ))
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.