Getting the average elapsed time from the event table

rdemaat

ADSM.ORG Member
Joined
Aug 19, 2008
Messages
92
Reaction score
1
Points
0
Hello,

I'm trying to get the average elapsed time for schedules from the event table. There are 14 entries per schedule. I want to add all 14 elapsed times and then average them. I have a couple select examples below but I've tried many different scenarios. The minutes column number should never be higher than 59. The first example shows 64 in the minutes column. The second example appears to be the same numbers just listed in a different format. I get the feeling I'm just adding elapsed time 'numbers' and averaging that number. Is it even possible to total 14 different HH:MM:SS time entries and then get the average of that time total? Thanks for any help you can give me on this.

NAHOLLAP846>
SELECT schedule_name, TRANSLATE('a bc:de:fg', DIGITS(AVG(completed-actual_start)), '_______abcdefgh_____',' ') as avg_runtime FROM events WHERE schedule_name like '%DM3-4%' and status = 'Completed' group by schedule_name

SCHEDULE_NAME AVG_RUNTIME
VM_DM3-4 0 00:64:91


NAHOLLAP846>
SELECT schedule_name, avg(time(completed) - time(actual_start)) as avg_runtime FROM events WHERE schedule_name like '%DM3-4%' and status = 'Completed' group by schedule_name

SCHEDULE_NAME AVG_RUNTIME
VM_DM3-4 6,491.857
 
After searching some more in this forum I found this below that works. Output is in minutes. It would be nice to have it convert back to HH:MM:SS but not a big deal.

SELECT schedule_name, cast(avg(timestampdiff(4,completed - actual_start)) as dec(12,0)) avg_runtime FROM events WHERE schedule_name like '%DM-6%' and status = 'Completed' group by schedule_name

SCHEDULE_NAME AVG_RUNTIME
VM_DM-6 17


NAHOLLAP846>
SELECT schedule_name, cast(avg(timestampdiff(4,completed - actual_start)) as dec(12,0)) avg_runtime FROM events WHERE schedule_name like '%DM4-1%' and status = 'Completed' group by schedule_name

SCHEDULE_NAME AVG_RUNTIME
VM_DM4-1 149

But if there are any other suggestions anyone has please pass them on. Thanks.
 
Back
Top