CREATE VIEW vwqueueinteractiondata AS (
SELECT queueinteractiondata.keyid,
queueinteractiondata.startdate,
queueinteractiondata.startdateltc,
queueinteractiondata.direction,
queueinteractiondata.queueid,
queuedetails.name AS queuename,
queuedetails.divisionid AS queue_divisionid,
divisiondetails.name AS queue_divisionname,
queueinteractiondata.mediatype,
queueinteractiondata.wrapupcode,
wrapupdetails.name AS wrapupdesc,
queueinteractiondata.talertcount,
queueinteractiondata.talerttimesum,
(queueinteractiondata.talerttimesum / 86400.00) AS talerttimesumday,
queueinteractiondata.talerttimemax,
(queueinteractiondata.talerttimemax / 86400.00) AS talerttimemaxday,
queueinteractiondata.talerttimemin,
(queueinteractiondata.talerttimemin / 86400.00) AS talerttimeminday,
queueinteractiondata.tansweredcount,
queueinteractiondata.tansweredtimesum,
(queueinteractiondata.tansweredtimesum / 86400.00) AS tansweredtimesumday,
queueinteractiondata.tansweredtimemax,
(queueinteractiondata.tansweredtimemax / 86400.00) AS tansweredtimemaxday,
queueinteractiondata.tansweredtimemin,
(queueinteractiondata.tansweredtimemin / 86400.00) AS tansweredtimeminday,
queueinteractiondata.ttalkcount,
queueinteractiondata.ttalktimesum,
(queueinteractiondata.ttalktimesum / 86400.00) AS ttalktimesumday,
queueinteractiondata.ttalktimemax,
(queueinteractiondata.ttalktimemax / 86400.00) AS ttalktimemaxday,
queueinteractiondata.ttalktimemin,
(queueinteractiondata.ttalktimemin / 86400.00) AS ttalktimeminday,
queueinteractiondata.ttalkcompletecount,
queueinteractiondata.ttalkcompletetimesum,
(queueinteractiondata.ttalkcompletetimesum / 86400.00) AS ttalkcompletetimesumday,
queueinteractiondata.ttalkcompletetimemax,
(queueinteractiondata.ttalkcompletetimemax / 86400.00) AS ttalkcompletetimemaxday,
queueinteractiondata.ttalkcompletetimemin,
(queueinteractiondata.ttalkcompletetimemin / 86400.00) AS ttalkcompletetimeminday,
queueinteractiondata.tnotrespondingcount,
queueinteractiondata.tnotrespondingtimesum,
(queueinteractiondata.tnotrespondingtimesum / 86400.00) AS tnotrespondingtimesumday,
queueinteractiondata.tnotrespondingtimemax,
(queueinteractiondata.tnotrespondingtimemax / 86400.00) AS tnotrespondingtimemaxday,
queueinteractiondata.tnotrespondingtimemin,
(queueinteractiondata.tnotrespondingtimemin / 86400.00) AS tnotrespondingtimeminday,
queueinteractiondata.theldcount,
queueinteractiondata.theldtimesum,
(queueinteractiondata.theldtimesum / 86400.00) AS theldtimesumday,
queueinteractiondata.theldtimemax,
(queueinteractiondata.theldtimemax / 86400.00) AS theldtimemaxday,
queueinteractiondata.theldtimemin,
(queueinteractiondata.theldtimemin / 86400.00) AS theldtimeminday,
queueinteractiondata.theldcompletecount,
queueinteractiondata.theldcompletetimesum,
(queueinteractiondata.theldcompletetimesum / 86400.00) AS theldcompletetimesumday,
queueinteractiondata.theldcompletetimemax,
(queueinteractiondata.theldcompletetimemax / 86400.00) AS theldcompletetimemaxday,
queueinteractiondata.theldcompletetimemin,
(queueinteractiondata.theldcompletetimemin / 86400.00) AS theldcompletetimeminday,
queueinteractiondata.thandlecount,
queueinteractiondata.thandletimesum,
(queueinteractiondata.thandletimesum / 86400.00) AS thandletimesumday,
queueinteractiondata.thandletimemax,
(queueinteractiondata.thandletimemax / 86400.00) AS thandletimemaxday,
queueinteractiondata.thandletimemin,
(queueinteractiondata.thandletimemin / 86400.00) AS thandletimeminday,
queueinteractiondata.tacwcount,
queueinteractiondata.tacwtimesum,
(queueinteractiondata.tacwtimesum / 86400.00) AS tacwtimesumday,
queueinteractiondata.tacwtimemax,
(queueinteractiondata.tacwtimemax / 86400.00) AS tacwtimemaxday,
queueinteractiondata.tacwtimemin,
(queueinteractiondata.tacwtimemin / 86400.00) AS tacwtimeminday,
queueinteractiondata.nconsult,
queueinteractiondata.nconsulttransferred,
queueinteractiondata.noutbound,
queueinteractiondata.nerror,
queueinteractiondata.ntransferred,
queueinteractiondata.nblindtransferred,
queueinteractiondata.nconnected,
queueinteractiondata.noffered,
queueinteractiondata.noversla,
queueinteractiondata.tacdcount,
queueinteractiondata.tacdtimesum,
(queueinteractiondata.tacdtimesum / 86400.00) AS tacdtimesumday,
queueinteractiondata.tacdtimemax,
(queueinteractiondata.tacdtimemax / 86400.00) AS tacdtimemaxday,
queueinteractiondata.tacdtimemin,
(queueinteractiondata.tacdtimemin / 86400.00) AS tacdtimeminday,
queueinteractiondata.tdialingcount,
queueinteractiondata.tdialingtimesum,
(queueinteractiondata.tdialingtimesum / 86400.00) AS tdialingtimesumday,
queueinteractiondata.tdialingtimemax,
(queueinteractiondata.tdialingtimemax / 86400.00) AS tdialingtimemaxday,
queueinteractiondata.tdialingtimemin,
(queueinteractiondata.tdialingtimemin / 86400.00) AS tdialingtimeminday,
queueinteractiondata.tcontactingcount,
queueinteractiondata.tcontactingtimesum,
(queueinteractiondata.tcontactingtimesum / 86400.00) AS tcontactingtimesumday,
queueinteractiondata.tcontactingtimemax,
(queueinteractiondata.tcontactingtimemax / 86400.00) AS tcontactingtimemaxday,
queueinteractiondata.tcontactingtimemin,
(queueinteractiondata.tcontactingtimemin / 86400.00) AS tcontactingtimeminday,
queueinteractiondata.tvoicemailcount,
queueinteractiondata.tvoicemailtimesum,
(queueinteractiondata.tvoicemailtimesum / 86400.00) AS tvoicemailtimesumday,
queueinteractiondata.tvoicemailtimemax,
(queueinteractiondata.tvoicemailtimemax / 86400.00) AS tvoicemailtimemaxday,
queueinteractiondata.tvoicemailtimemin,
(queueinteractiondata.tvoicemailtimemin / 86400.00) AS tvoicemailtimeminday,
queueinteractiondata.tflowoutcount,
queueinteractiondata.tflowouttimesum,
(queueinteractiondata.tflowouttimesum / 86400.00) AS tflowouttimesumday,
queueinteractiondata.tflowouttimemax,
(queueinteractiondata.tflowouttimemax / 86400.00) AS tflowouttimemaxday,
queueinteractiondata.tflowouttimemin,
(queueinteractiondata.tflowouttimemin / 86400.00) AS tflowouttimeminday,
queueinteractiondata.twaitcount,
queueinteractiondata.twaittimesum,
(queueinteractiondata.twaittimesum / 86400.00) AS twaittimesumday,
queueinteractiondata.twaittimemax,
(queueinteractiondata.twaittimemax / 86400.00) AS twaittimemaxday,
queueinteractiondata.twaittimemin,
(queueinteractiondata.twaittimemin / 86400.00) AS twaittimeminday,
(sum(queueinteractiondata.twaittimesum) / (sum(queueinteractiondata.twaitcount))::numeric) AS twaittimeavg,
queueinteractiondata.tabandoncount,
queueinteractiondata.tabandontimesum,
(queueinteractiondata.tabandontimesum / 86400.00) AS tabandontimesumday,
queueinteractiondata.tabandontimemax,
(queueinteractiondata.tabandontimemax / 86400.00) AS tabandontimemaxday,
queueinteractiondata.tabandontimemin,
(queueinteractiondata.tabandontimemin / 86400.00) AS tabandontimeminday,
(sum(queueinteractiondata.tabandontimesum) / (sum(queueinteractiondata.tabandoncount))::numeric) AS tabandontimeavg,
((sum(queueinteractiondata.tabandontimesum) / (sum(queueinteractiondata.tabandoncount))::numeric) / 86400.00) AS tabandontimeavgday,
(sum(queueinteractiondata.tabandoncount) / NULLIF(sum(queueinteractiondata.noffered), 0)) AS tabandoncountavg,
queueinteractiondata.servicelevelnumerator,
queueinteractiondata.serviceleveldenominator,
(sum(queueinteractiondata.servicelevelnumerator) / sum(queueinteractiondata.serviceleveldenominator)) AS servicelevelcalc,
queueinteractiondata.av1count,
queueinteractiondata.av1timesum,
(queueinteractiondata.av1timesum / 86400.00) AS av1timesumday,
queueinteractiondata.av1timemax,
(queueinteractiondata.av1timemax / 86400.00) AS av1timemaxday,
queueinteractiondata.av1timemin,
(queueinteractiondata.av1timemin / 86400.00) AS av1timeminday,
queueinteractiondata.av2count,
queueinteractiondata.av2timesum,
(queueinteractiondata.av2timesum / 86400.00) AS av2timesumday,
queueinteractiondata.av2timemax,
(queueinteractiondata.av2timemax / 86400.00) AS av2timemaxday,
queueinteractiondata.av2timemin,
(queueinteractiondata.av2timemin / 86400.00) AS av2timeminday,
queueinteractiondata.av3count,
queueinteractiondata.av3timesum,
(queueinteractiondata.av3timesum / 86400.00) AS av3timesumday,
queueinteractiondata.av3timemax,
(queueinteractiondata.av3timemax / 86400.00) AS av3timemaxday,
queueinteractiondata.av3timemin,
(queueinteractiondata.av3timemin / 86400.00) AS av3timeminday,
queueinteractiondata.av4count,
queueinteractiondata.av4timesum,
(queueinteractiondata.av4timesum / 86400.00) AS av4timesumday,
queueinteractiondata.av4timemax,
(queueinteractiondata.av4timemax / 86400.00) AS av4timemaxday,
queueinteractiondata.av4timemin,
(queueinteractiondata.av4timemin / 86400.00) AS av4timeminday,
queueinteractiondata.av5count,
queueinteractiondata.av5timesum,
(queueinteractiondata.av5timesum / 86400.00) AS av5timesumday,
queueinteractiondata.av5timemax,
(queueinteractiondata.av5timemax / 86400.00) AS av5timemaxday,
queueinteractiondata.av5timemin,
(queueinteractiondata.av5timemin / 86400.00) AS av5timeminday,
queueinteractiondata.av6count,
queueinteractiondata.av6timesum,
(queueinteractiondata.av6timesum / 86400.00) AS av6timesumday,
queueinteractiondata.av6timemax,
(queueinteractiondata.av6timemax / 86400.00) AS av6timemaxday,
queueinteractiondata.av6timemin,
(queueinteractiondata.av6timemin / 86400.00) AS av6timeminday,
queueinteractiondata.av7count,
queueinteractiondata.av7timesum,
(queueinteractiondata.av7timesum / 86400.00) AS av7timesumday,
queueinteractiondata.av7timemax,
(queueinteractiondata.av7timemax / 86400.00) AS av7timemaxday,
queueinteractiondata.av7timemin,
(queueinteractiondata.av7timemin / 86400.00) AS av7timeminday,
queueinteractiondata.av8count,
queueinteractiondata.av8timesum,
(queueinteractiondata.av8timesum / 86400.00) AS av8timesumday,
queueinteractiondata.av8timemax,
(queueinteractiondata.av8timemax / 86400.00) AS av8timemaxday,
queueinteractiondata.av8timemin,
(queueinteractiondata.av8timemin / 86400.00) AS av8timeminday,
queueinteractiondata.av9count,
queueinteractiondata.av9timesum,
(queueinteractiondata.av9timesum / 86400.00) AS av9timesumday,
queueinteractiondata.av9timemax,
(queueinteractiondata.av9timemax / 86400.00) AS av9timemaxday,
queueinteractiondata.av9timemin,
(queueinteractiondata.av9timemin / 86400.00) AS av9timeminday,
queueinteractiondata.av10count,
queueinteractiondata.av10timesum,
(queueinteractiondata.av10timesum / 86400.00) AS av10timesumday,
queueinteractiondata.av10timemax,
(queueinteractiondata.av10timemax / 86400.00) AS av10timemaxday,
queueinteractiondata.av10timemin,
(queueinteractiondata.av10timemin / 86400.00) AS av10timeminday,
queueinteractiondata.updated
FROM (((queueinteractiondata queueinteractiondata
LEFT JOIN queuedetails queuedetails ON (((queuedetails.id)::text = (queueinteractiondata.queueid)::text)))
LEFT JOIN wrapupdetails wrapupdetails ON (((wrapupdetails.id)::text = (queueinteractiondata.wrapupcode)::text)))
LEFT JOIN divisiondetails divisiondetails ON (((queuedetails.divisionid)::text = (divisiondetails.id)::text)))
GROUP BY queueinteractiondata.keyid, queueinteractiondata.startdate, queueinteractiondata.startdateltc, queueinteractiondata.direction, queueinteractiondata.queueid, queuedetails.name, queuedetails.divisionid, divisiondetails.name, queueinteractiondata.mediatype, queueinteractiondata.wrapupcode, wrapupdetails.name, queueinteractiondata.talertcount, queueinteractiondata.talerttimesum, queueinteractiondata.talerttimemax, queueinteractiondata.talerttimemin, queueinteractiondata.tansweredcount, queueinteractiondata.tansweredtimesum, queueinteractiondata.tansweredtimemax, queueinteractiondata.tansweredtimemin, queueinteractiondata.ttalkcount, queueinteractiondata.ttalktimesum, queueinteractiondata.ttalktimemax, queueinteractiondata.ttalktimemin, queueinteractiondata.ttalkcompletecount, queueinteractiondata.ttalkcompletetimesum, queueinteractiondata.ttalkcompletetimemax, queueinteractiondata.ttalkcompletetimemin, queueinteractiondata.tnotrespondingcount, queueinteractiondata.tnotrespondingtimesum, queueinteractiondata.tnotrespondingtimemax, queueinteractiondata.tnotrespondingtimemin, queueinteractiondata.theldcount, queueinteractiondata.theldtimesum, queueinteractiondata.theldtimemax, queueinteractiondata.theldtimemin, queueinteractiondata.theldcompletecount, queueinteractiondata.theldcompletetimesum, queueinteractiondata.theldcompletetimemax, queueinteractiondata.theldcompletetimemin, queueinteractiondata.thandlecount, queueinteractiondata.thandletimesum, queueinteractiondata.thandletimemax, queueinteractiondata.thandletimemin, queueinteractiondata.tacwcount, queueinteractiondata.tacwtimesum, queueinteractiondata.tacwtimemax, queueinteractiondata.tacwtimemin, queueinteractiondata.nconsult, queueinteractiondata.nconsulttransferred, queueinteractiondata.noutbound, queueinteractiondata.nerror, queueinteractiondata.ntransferred, queueinteractiondata.nblindtransferred, queueinteractiondata.nconnected, queueinteractiondata.noffered, queueinteractiondata.noversla, queueinteractiondata.tacdcount, queueinteractiondata.tacdtimesum, queueinteractiondata.tacdtimemax, queueinteractiondata.tacdtimemin, queueinteractiondata.tdialingcount, queueinteractiondata.tdialingtimesum, queueinteractiondata.tdialingtimemax, queueinteractiondata.tdialingtimemin, queueinteractiondata.tcontactingcount, queueinteractiondata.tcontactingtimesum, queueinteractiondata.tcontactingtimemax, queueinteractiondata.tcontactingtimemin, queueinteractiondata.tvoicemailcount, queueinteractiondata.tvoicemailtimesum, queueinteractiondata.tvoicemailtimemax, queueinteractiondata.tvoicemailtimemin, queueinteractiondata.tflowoutcount, queueinteractiondata.tflowouttimesum, queueinteractiondata.tflowouttimemax, queueinteractiondata.tflowouttimemin, queueinteractiondata.twaitcount, queueinteractiondata.twaittimesum, queueinteractiondata.twaittimemax, queueinteractiondata.twaittimemin, queueinteractiondata.tabandoncount, queueinteractiondata.tabandontimesum, queueinteractiondata.tabandontimemax, queueinteractiondata.tabandontimemin, queueinteractiondata.servicelevelnumerator, queueinteractiondata.serviceleveldenominator, queueinteractiondata.av1count, queueinteractiondata.av1timesum, queueinteractiondata.av1timemax, queueinteractiondata.av1timemin, queueinteractiondata.av2count, queueinteractiondata.av2timesum, queueinteractiondata.av2timemax, queueinteractiondata.av2timemin, queueinteractiondata.av3count, queueinteractiondata.av3timesum, queueinteractiondata.av3timemax, queueinteractiondata.av3timemin, queueinteractiondata.av4count, queueinteractiondata.av4timesum, queueinteractiondata.av4timemax, queueinteractiondata.av4timemin, queueinteractiondata.av5count, queueinteractiondata.av5timesum, queueinteractiondata.av5timemax, queueinteractiondata.av5timemin, queueinteractiondata.av6count, queueinteractiondata.av6timesum, queueinteractiondata.av6timemax, queueinteractiondata.av6timemin, queueinteractiondata.av7count, queueinteractiondata.av7timesum, queueinteractiondata.av7timemax, queueinteractiondata.av7timemin, queueinteractiondata.av8count, queueinteractiondata.av8timesum, queueinteractiondata.av8timemax, queueinteractiondata.av8timemin, queueinteractiondata.av9count, queueinteractiondata.av9timesum, queueinteractiondata.av9timemax, queueinteractiondata.av9timemin, queueinteractiondata.av10count, queueinteractiondata.av10timesum, queueinteractiondata.av10timemax, queueinteractiondata.av10timemin, queueinteractiondata.updated
)