Average Response Time

Below is a PostgreSQL example how to get the average response time for the first quarter in a way that non-working hours and weekends are not included.
If the request came at 17:02, it is calculated as it came the day after at 8:00.

SELECT avg((SELECT sum(case when dif<‘0:00’::time then dif+interval ‘8 hour’ else dif end)
                          FROM ( SELECT i::time-lag(i,1) over (order by i)::time as dif
                                         FROM generate_series(received, accepted, interval ‘1 minute’) i
                                         WHERE date_part(‘dow’, i) not in (0, 6)
                                                         and i::time between ’08:00′ and ’16:00′
                                       ) tbl
FROM csr
WHERE priority=’High’ and extract (quarter from received)=1


Ovaj unos je objavljen u Nekategorizirano. Bookmarkirajte stalnu vezu.


Popunite niže tražene podatke ili kliknite na neku od ikona za prijavu:

WordPress.com Logo

Ovaj komentar pišete koristeći vaš WordPress.com račun. Odjava / Izmijeni )

Twitter picture

Ovaj komentar pišete koristeći vaš Twitter račun. Odjava / Izmijeni )

Facebook slika

Ovaj komentar pišete koristeći vaš Facebook račun. Odjava / Izmijeni )

Google+ photo

Ovaj komentar pišete koristeći vaš Google+ račun. Odjava / Izmijeni )

Spajanje na %s