System information
avg(case when b.realduration > 0 then b.realduration else null end) as 'ACD (sec)'
FROM tb_cdrs b WITH(NOLOCK) WHERE
b.datum >= :from AND b.datum <= :to
GROUP BY b.marker ORDER BY b.marker
--stats by call quality
SELECT
b.marker, count(b.id) as 'CDRC (count)',
sum(b.realduration)/60 as 'SL (min)',
sum(SIGN(b.realduration))*100/count(b.id) as 'ASR (%)',
avg(case when b.realduration > 0 then b.realduration else null end) as 'ACD (sec)' ,
avg(
case
when realduration > 5 and realduration < 35 and (rtpsent > 400 or rtprec > 400) and
(
(rtpsent >= 0 and rtpsent < rtprec/9) or
(rtprec >= 0 and rtprec < rtpsent/9) or
(rtplost > rtpsent/2)
)
then 0
when realduration > 5 and realduration < 55 and (rtpsent > 400 or rtprec > 400) and
(
(rtpsent >= 0 and rtpsent < rtprec/2) or
(rtprec >= 0 and rtprec < rtpsent/2) or
(rtplost > rtpsent/4)
)
then 2
when realduration > 55 and rtpsent > 2000 and rtprec > 2000 and
(
(rtpsent > rtprec/2) or
(rtprec > rtpsent/2) or
(rtplost < rtpsent/6)
)
then 8
when realduration > 120 and rtpsent > 2000 and rtprec > 2000 and
(
(rtpsent > rtprec/2) or
(rtprec > rtpsent/2) or
(rtplost < rtpsent/6)
)
then 10










