Skip to content
Advertisement

Is there a way to calculate the average queue time of an entire column that contains data in time format

I have imported a data extracted from a cisco call center in SQLITE table. These data deals with information related to the incoming calls .

Among this table , there is a column called “queue time” which indicates the time spent by the caller waiting in the queue before reaching an agent . I would like to write a select query that calcultes the average time of the “queuetime” and the result should be in time format . I tried with many queries but without any success:

SELECT strftime('%H:%M:%S',AVG("QUEUETIME")) 
FROM "CSQ Agent Report"

The result is the following:

[('12:00:00',), ('12:00:00',), ('12:00:00',), ('12:00:00',), ('12:00:00',), ('12:00:00',)]

For:

SELECT  AVG("QUEUETIME"))) FROM "CSQ Agent Report"

The result is the folowing:

[(0.0,)]

Here is a partial copy of the Queuetime column :

00:00:05
00:00:05
00:00:08
00:00:03
00:00:02
00:01:45
00:00:05
00:00:03
00:00:06
00:00:24
00:00:06
00:00:46

Thanks for your support

Advertisement

Answer

You must convert the time values to numbers which are unix timestamps since the start of epoch which is '1970-01-01 00:00:00' to perform the average calculation and after you get the numeric result you must convert back to time with the function time():

SELECT TIME(AVG(strftime('%s', Queuetime)), 'unixepoch') avg_time
FROM CSQAgentReport

See the demo.
Results:

> | avg_time |
> | :------- |
> | 00:00:18 |
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement