CREATE VIEW vwqueueconvrealtime AS (
SELECT queuerealtimeconvdata.conversationid,
queuerealtimeconvdata.media,
queuerealtimeconvdata.actingas,
queuerealtimeconvdata.conversationstate,
datediff('second'::character varying, queuerealtimeconvdata.startdate, timezone('utc'::text, now())) AS statustimesecs,
((datediff('second'::character varying, queuerealtimeconvdata.startdate, timezone('utc'::text, now())))::numeric / 86400.00) AS statusdays,
(((datediff('second'::character varying, queuerealtimeconvdata.startdate, timezone('utc'::text, now())))::double precision * '00:00:01'::interval))::character varying AS "StatusTimeFormatted",
queuerealtimeconvdata.skill1,
skill1.name AS skillname1,
queuerealtimeconvdata.skill2,
skill2.name AS skillname2,
queuerealtimeconvdata.skill3,
skill3.name AS skillname3,
queuerealtimeconvdata.initialpriority,
queuerealtimeconvdata.participantname,
queuerealtimeconvdata.queueid,
queuedetails.name AS queuename,
queuedetails.divisionid AS division,
divisiondetails.name AS divisionname,
queuerealtimeconvdata.userid,
userdetail.name,
userdetail.department,
userdetail.managername,
queuerealtimeconvdata.direction,
queuerealtimeconvdata.ani,
queuerealtimeconvdata.dnis,
queuerealtimeconvdata.requestedrout1,
queuerealtimeconvdata.requestedrout2,
queuerealtimeconvdata.usedrout
FROM ((((((queuerealtimeconvdata queuerealtimeconvdata
LEFT JOIN skilldetails skill1 ON (((skill1.id)::text = (queuerealtimeconvdata.skill1)::text)))
LEFT JOIN skilldetails skill2 ON (((skill2.id)::text = (queuerealtimeconvdata.skill2)::text)))
LEFT JOIN skilldetails skill3 ON (((skill3.id)::text = (queuerealtimeconvdata.skill3)::text)))
LEFT JOIN queuedetails queuedetails ON (((queuedetails.id)::text = (queuerealtimeconvdata.queueid)::text)))
LEFT JOIN divisiondetails divisiondetails ON (((divisiondetails.id)::text = (queuedetails.divisionid)::text)))
LEFT JOIN vwuserdetail userdetail ON (((userdetail.id)::text = (queuerealtimeconvdata.userid)::text)))
)